So I have this Finch robot and I've been creating a menu system for it. I would like to make the system such that it has certain constraints. Here is my code:
I've posted the menu system as you can see. An example of a constraint I want to add is say the user selects the "Forward" command and this executes, then directly after the user selects "Forward" again, I want to make this give an error, so that a "Fowarward" command cannot be chose directly after a "Forward" command.
I've been thinking of if statements but I'm really stuck. Your help is greatly appreciated.
import javax.swing.JOptionPane;
import edu.cmu.ri.createlab.terk.robot.finch.Finch;
public class RobotController
{
private static Finch myf = null;
public static void main(String args[])
{
myf = new Finch(); // Object
String c = "";
do
{
c = FinchController();
if (c == "Forward") MoveForward(c);
if (c=="Back")MoveBack(c);
if (c == "Left Turn") MoveLeft(c);
if (c == "Right Turn") MoveRight(c);
if (c == "Nose Colour") GreenLED(c);
if (c == "Three Point Turn") ThreePointTurn(c);
//if (c == "Input Command File")InputCommandFile(c);
}
while (c != "End Program");
myf.quit();
}
private static String FinchController()
{
Object[] possibilities = {"Forward","Left Turn","Right Turn", "Nose Colour" ,"Three Point Turn","Input Command File","End Program"};
String c = (String)JOptionPane.showInputDialog(null,"Robot Controller \n\nChoose a command:\n\n","Robot Controller",JOptionPane.PLAIN_MESSAGE, null,possibilities,"Forward");
if (c == null || c.length() == 0) c = "Quit";return(c);
}
I've posted the menu system as you can see. An example of a constraint I want to add is say the user selects the "Forward" command and this executes, then directly after the user selects "Forward" again, I want to make this give an error, so that a "Fowarward" command cannot be chose directly after a "Forward" command.
I've been thinking of if statements but I'm really stuck. Your help is greatly appreciated.