PDA

Click to See Complete Forum and Search --> : Urgent Help - Else Without If


hshah
Oct 26th, 2004, 10:05 PM
{ if (robot.getHeading() == IRobot.NORTH)
northController(robot);
robot.face(northController(robot));
else if (robot.getHeading() == IRobot.EAST)
eastController(robot);
robot.face(eastController(robot));
else if (robot.getHeading() == IRobot.SOUTH)
southController(robot);
robot.face(southController(robot));
else if (robot.getHeading() == IRobot.WEST)
westController(robot);
robot.face(westController(robot));
}


I keep getting else without if errors and there are 3 of them which point at the three elses!

Any ideas how to fix the problem please?

brown monkey
Oct 26th, 2004, 10:50 PM
{ if (robot.getHeading() == IRobot.NORTH){
northController(robot);
robot.face(northController(robot));
}
else if (robot.getHeading() == IRobot.EAST){
eastController(robot);
robot.face(eastController(robot));
}
else if (robot.getHeading() == IRobot.SOUTH){
southController(robot);
robot.face(southController(robot));
}
else if (robot.getHeading() == IRobot.WEST){
westController(robot);
robot.face(westController(robot));
}
}


?