aleantorcha

Untitled

Nov 21st, 2019
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. /**
  2. * Class for the Roof Builders
  3. * By: Alejandro Antorcha
  4. */
  5. package Lesson3;
  6.  
  7. import kareltherobot.World;
  8.  
  9. public class RoofBuilder extends Constructicon {
  10.  
  11. public RoofBuilder(int x, int y, Direction d, int b) {
  12. super(x, y, d, b);
  13. }
  14.  
  15. /**
  16. * makes the robot appear to turn right
  17. * @param
  18. * @return void
  19. */
  20. public void turnRight() {
  21. //changing the delay to 0
  22. int delay = World.delay();
  23. World.setDelay(0);
  24. turnLeft();
  25. turnLeft();
  26.  
  27. //setting the relay to what it was previously set to
  28. World.setDelay(delay);
  29.  
  30. turnLeft();
  31. }
  32.  
  33. /**
  34. * One movement up a step
  35. * @param
  36. * @return void
  37. */
  38. public void stepMove() {
  39. move();
  40. turnRight();
  41. move();
  42. turnLeft();
  43. }
  44.  
  45. /**
  46. * Builds a roof for the house
  47. * @param
  48. * @return void
  49. */
  50. public void build() {
  51. //builds the left of the roof
  52. for(int i = 0; i < 5; i++) {
  53. putBeeper();
  54. stepMove();
  55. }
  56.  
  57. //turns right to orient second part ov the building of the roof
  58. turnRight();
  59.  
  60. //builds the right of the roof
  61. for(int i = 0; i < 5; i++) {
  62. putBeeper();
  63. stepMove();
  64. }
  65.  
  66. //puts the last beeper
  67. putBeeper();
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment