Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import stanford.karel.*;
- public class CheckerboardKarel extends SuperKarel {
- public void run() {
- while (frontIsClear()) {
- putBeeper();
- advancedMove();
- advancedMove();
- }
- }
- private void advancedMove() {
- if (frontIsClear()) {
- move();
- } else {
- if (facingNorth()) {
- } else {
- if (facingEast()) {
- turnLeft();
- if (frontIsClear()) {
- move();
- turnLeft();
- }
- } else {
- if (facingWest()) {
- turnRight();
- if (frontIsClear()) {
- move();
- turnRight();
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement