Learn for and while loops. Learn about certain commands that return a true/false value.
for(counter start; counter stop test; counter increment) {
body of the loop
}
Example:
for(int i=0; i<n ; i++) {
robot.pickBeeper();
}
while(test condition(s)) {
body of the loop
}
The test condition(s) are functions that return true or false
Example:
while(robot.nextToABeeper()) {
robot.pickBeeper();
}
while (!robo1.rightIsClear() && !robo1.nextToABeeper()) {
commands
}
facingEast()
facingNorth()
facingSouth()
facingWest()
frontIsClear()
leftIsClear()
nextToABeeper()
nextToARobot()
if(boolean statement(s)) {
body of if
} else {
alternative body
}
The "else" portion is optional