Advertisement
GARC923

Untitled

Sep 13th, 2022
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. /*
  2. Carlos Garcia
  3. Lesson 2 Activity 3
  4. Running laps
  5. */
  6.  
  7. {
  8.  
  9.     public static void main(String[] args) {
  10.         World.setDelay(10);
  11.         World.setVisible();
  12.         World.setBeeperColor(Color.blue);
  13.         World.readWorld("Lesson2World1.kwld");
  14.  
  15.         UrRobot zgod = new UrRobot(5, 3, North, -1);
  16.  
  17.         // making robot face right
  18.         zgod.turnLeft();
  19.         zgod.turnLeft();
  20.         zgod.turnLeft();
  21.  
  22.         // loop that goes half the rectangle. Runs 10 times in order to do 5 full laps
  23.         for (int i=0; i<10; i++){
  24.             zgod.putBeeper();
  25.             zgod.move();
  26.             zgod.move();
  27.             zgod.move();
  28.             zgod.move();
  29.             zgod.putBeeper();
  30.             zgod.turnLeft();
  31.             zgod.move();
  32.             zgod.move();
  33.             zgod.turnLeft();
  34.         }
  35.  
  36.         // final move to face right direction at the end
  37.         zgod.move();
  38.         zgod.turnLeft();
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement