Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. /*
  2. * File: CollectNewspaperKarel.java
  3. * --------------------------------
  4. * At present, the CollectNewspaperKarel subclass does nothing.
  5. * Your job in the assignment is to add the necessary code to
  6. * instruct Karel to walk to the door of its house, pick up the
  7. * newspaper (represented by a beeper, of course), and then return
  8. * to its initial position in the upper left corner of the house.
  9. */
  10.  
  11. import stanford.karel.*;
  12.  
  13. public class CollectNewspaperKarel extends Karel {
  14. public void run () {
  15. turnRight();
  16. move();
  17. turnLeft();
  18. move();
  19. move();
  20. move();
  21. pickBeeper();
  22. turnAround();
  23. move();
  24. move();
  25. move();
  26. turnRight();
  27. move();
  28. turnRight();
  29.  
  30. }
  31.  
  32. public void turnRight() {
  33. turnLeft();
  34. turnLeft();
  35. turnLeft();
  36.  
  37. }
  38.  
  39. public void turnAround(){
  40. turnLeft();
  41. turnLeft();
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement