Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. /*
  2. * File: CheckerboardKarel.java
  3. * ----------------------------
  4. * When you finish writing it, the CheckerboardKarel class should draw
  5. * a checkerboard using beepers, as described in Assignment 1. You
  6. * should make sure that your program works for all of the sample
  7. * worlds supplied in the starter folder.
  8. */
  9.  
  10. import stanford.karel.*;
  11.  
  12. public class CheckerboardKarel extends SuperKarel {
  13.  
  14.  
  15. public void run(){
  16. while (frontIsClear()){
  17. putBeeper();
  18. move();
  19. if (frontIsClear()){
  20. move();
  21. } else {
  22. if (facingEast()){
  23. turnLeft();
  24. move();
  25. turnLeft();
  26. } else {
  27. if (facingWest()){
  28. turnRight();
  29. move();
  30. turnRight();
  31. }
  32. }
  33.  
  34. }
  35.  
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement