Quote:
Originally Posted by SoftwareBug2.0
That looks like it would work. I was pretty sure it would be possible to do something but I thought it might get really ugly really fast. That's a pretty slick way to do it.
Here's something you could do if you wanted to be avoid duplicating the end of command conditions in the subsequent if:
Code:
class Continuable extends Command{
//I don't remember whether I've set this class up is valid Java...
//this would return self unless you wnated to run a different command.
abstract public Continuable next();
public bool isFinished(){
return next()==null;
}
}
class Continues extends Command{
Continuable current;
Continues(Continuable cmd){
current=cmd;
}
void initialize(){
if(current!=null) current.initialize();
}
void execute(){
if(current!=null){
current.execute();
}
}
bool isFinished(){
if(current==null) return 1;
current=current.next();
return current==null;
}
}
|
Thanks. This is one of the topics I want to tackle this off season. I'm still struggling with the best way to store the decision, in a command or in another object of some sort that gets passed around. It probably depends on the usage.