KUEM011

Untitled

Nov 22nd, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. {
  2.     /**
  3.      * @param x
  4.      * @param y
  5.      * @param d
  6.      * @param b
  7.      */
  8.     public Lesson3Activity2(int x, int y, Direction d, int b){
  9.  
  10.         super(x, y, d, b);
  11.     }
  12.     /*
  13.     Allows the robot to turn right to help his stepping process
  14.      */
  15.     public void turnRight(){
  16.         int delay = World.delay();
  17.         World.setDelay(0);
  18.         turnLeft();
  19.         turnLeft();
  20.         turnLeft();
  21.         World.setDelay(delay);
  22.  
  23.     }
  24.     /*
  25.     Makes the code for one single step so that this can be repeated
  26.      */
  27.     public void oneStep(){
  28.         move();
  29.         turnRight();
  30.         move();
  31.         pickBeeper();
  32.         turnLeft();
  33.     }
  34.  
  35.     /**
  36.      This code allows for the world to be created, and for the robot to go up the steps.
  37.      * @param args
  38.      */
  39.     public static void main(String[] args){
  40.         World.setDelay(20);
  41.         World.setVisible(); //Creates the world that the robot will live in.
  42.         World.readWorld("Lesson3World2.kwld"); //Creates the world and the robot.
  43.         Lesson3Activity2 roomba = new Lesson3Activity2(1, 1, North, 0);
  44.         for (int index = 0; index < 7; index++){
  45.             roomba.oneStep();
  46.         }
  47.         //Simple for loop so that each step repeats itself.
  48.     }
  49.  
  50. }
Add Comment
Please, Sign In to add comment