View Single Post
  #30   Spotlight this post!  
Unread 03-05-2014, 14:40
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Share you Autonomous

Quote:
Originally Posted by SoftwareBug2.0 View Post
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.