02-02-2018, 01:29 PM
I made this. 3 simple functions with overloads to cover all possible parameter combinations. The problem is that code lenght scales expotentially with number of parameters. Is there smarter/shorter way to make function with parameters that can be different types?
Code:
extern void object::Libr(){}
public object object::pick(point p) {
goto(p);
grab();
return load;
}
public object object::pick(object o) {
return pick(o.position);
}
public object object::pick(int cat) {
return pick(radar(cat));
}
public void put(point p){
goto(p);
drop();
}
public void put(object o){
put(o.position);
}
public void put(int cat){
put(radar(cat));
}
public void transport(point what, point where){
pick(what);
put(where);
}
public void transport(point what, object where){
transport(what, where.position);
}
public void transport(point what, int where){
transport(what, radar(where));
}
public void transport(object what, point where){
transport(what.position, where);
}
public void transport(object what, object where){
transport(what.position, where.position);
}
public void transport(object what, int where){
transport(what.position, radar(where));
}
public void transport(int what, point where){
transport(radar(what), where);
}
public void transport(int what, object where){
transport(radar(what), where.position);
}
public void transport(int what, int where){
transport(radar(what), radar(where));
}