Advertisement
fu011

Untitled

Nov 21st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.82 KB | None | 0 0
  1. // bobby does cardio program
  2.  
  3. package Lesson3;
  4. import kareltherobot.*;
  5.  
  6. public class Lesson3Activity1 extends UrRobot {
  7.     public Lesson3Activity1(int x, int y, Direction d, int b) {
  8.         super(x, y, d, b);
  9.     }
  10.  
  11.     /**
  12.      * robot turns right
  13.      * @param
  14.      * @return
  15.      */
  16.     public void turnRight() {
  17.         int delay = World.delay();
  18.         World.setDelay(0);
  19.         turnLeft();
  20.         turnLeft();
  21.         World.setDelay(delay);
  22.         turnLeft();
  23.     }
  24.  
  25.     /**
  26.      * robot moves up three times
  27.      * @param
  28.      * @return
  29.      */
  30.     public void moveUp() {
  31.         move();
  32.         move();
  33.         move();
  34.     }
  35.  
  36.     /**
  37.      * robot is running up and down while picking up beepers
  38.      * @param
  39.      * @return
  40.      */
  41.     public void laneRunning () {
  42.         moveUp();
  43.         pickBeeper();
  44.         turnRight();
  45.         turnRight();
  46.         moveUp();
  47.         putBeeper();
  48.         turnLeft();
  49.         turnLeft();
  50.  
  51.     }
  52.  
  53.     /**
  54.      * robot is switching lanes
  55.      * @param
  56.      * @return
  57.      */
  58.     public void switchLanes () {
  59.         turnRight();
  60.         move();
  61.         turnLeft();
  62.     }
  63.  
  64.     /**
  65.      * robot does a full set of shuttle runs
  66.      * @param
  67.      * @return
  68.      */
  69.     public void runningAround () {
  70.  
  71.         laneRunning();
  72.         laneRunning();
  73.         laneRunning();
  74.         laneRunning();
  75.         laneRunning();
  76.     }
  77.     public static void main(String[] args) {
  78.         Lesson3Activity1 bobby = new Lesson3Activity1(4, 3, North, 5);
  79.         World.setDelay(10);
  80.         World.setVisible();
  81.         World.readWorld("Lesson3World1.kwld");
  82.         bobby.runningAround();
  83.         bobby.switchLanes();
  84.         bobby.runningAround();
  85.         bobby.switchLanes();
  86.         bobby.runningAround();
  87.         bobby.move();
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement