Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. package Lesson3;
  2. import kareltherobot.*;
  3.  
  4. public class Lesson3Activity2 extends UrRobot{
  5.  
  6. //constructor from UrRobot for my alphabot
  7. public Lesson3Activity2(int x, int y, Direction d, int b) {
  8. super(x, y, d, b);
  9. }
  10.  
  11. public static void main(String[] args) {
  12. World.readWorld("Lesson3World2.kwld");
  13.  
  14. World.setDelay(30);
  15. World.setVisible();
  16.  
  17. Lesson3Activity2 alphaBot = new Lesson3Activity2(1,1,North, 0);
  18.  
  19. //climbs the steps 7 times
  20. for(int i = 0; i < 7; i++) {
  21. alphaBot.stairClimb();
  22. }
  23. }
  24.  
  25. /**
  26. * makes the robot climb one staircase
  27. * @param
  28. * @return void
  29. */
  30. public void stairClimb() {
  31. move();
  32. turnRight();
  33. move();
  34. pickBeeper();
  35. turnLeft();
  36. }
  37.  
  38. /**
  39. * makes robot appear to turn right
  40. * @param
  41. * @return void
  42. */
  43. public void turnRight() {
  44. //changing the delay to 0
  45. int delay = World.delay();
  46. World.setDelay(0);
  47.  
  48. turnLeft();
  49. turnLeft();
  50.  
  51. //setting the relay to what it was previously set to
  52. World.setDelay(delay);
  53. turnLeft();
  54. }
  55.  
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement