im doing this online stanford engineering class that's using karel the robot to teach programming basics. karel lives in a grid where he can put, and pick up beepers, move, turn left, and turn right. I have to turn a grid of any dimensions into a checker board by placing beepers in a checker board pattern. I made this program and it works but he ends up running into the wall at the end. can anybody help me fix this? here's the program:
JAVA Code:
import stanford.karel.*;
public class CheckerboardKarel extends SuperKarel {
public void run() {
moveQuick();
}
private void moveQuick() {
putBeeper();
moveNow();
moveNow();
moveQuick();
}
private void moveNow() {
if(frontIsClear()) {
move();
} else {
if(facingEast()) {
turnLeft();
move();
turnLeft();
} else {
turnRight();
move();
turnRight();
}
}
}
}