Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. /*
  2. * File: StoneMasonKarel.java
  3. * --------------------------
  4. * The StoneMasonKarel subclass as it appears here does nothing.
  5. * When you finish writing it, it should solve the "repair the quad"
  6. * problem from Assignment 1. In addition to editing the program,
  7. * you should be sure to edit this comment so that it no longer
  8. * indicates that the program does nothing.
  9. */
  10.  
  11. import stanford.karel.*;
  12.  
  13. public class StoneMasonKarel extends SuperKarel {
  14.  
  15. public void run () {
  16. turnLeft();
  17. fixColumn();
  18. turnRight();
  19. for (int i=0; i<4;i++){
  20. move();
  21. }
  22. turnRight();
  23. fixColumn();
  24. turnLeft();
  25. for (int i=0; i<4;i++){
  26. move();
  27. }
  28. turnLeft();
  29. fixColumn();
  30. turnRight();
  31. for (int i=0; i<4;i++){
  32. move();
  33. }
  34. turnRight();
  35. fixColumn();
  36. turnLeft();
  37. }
  38. public void fixColumn(){
  39. for (int i=0; i<4;i++){
  40. while (noBeepersPresent()){
  41. putBeeper();
  42. }
  43. move();
  44. }
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement