Advertisement
GARC923

Lesson 4 Acitivy 1

Oct 21st, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. /**
  2. Carlos Garcia
  3. Lesson 4 Activity 1
  4. Left is Clear
  5. */
  6.  
  7. package Lesson4;
  8.  
  9. import kareltherobot.Robot;
  10. import kareltherobot.World;
  11.  
  12.  
  13. public class Activity1 extends EsperBot {
  14.     public Activity1(int street, int avenue, Direction direction, int beeperCount) {
  15.         super(street, avenue, direction, beeperCount);
  16.     }
  17.  
  18.  
  19.     public static void main(String[] args) {
  20.         World.setDelay(50);
  21.         World.setVisible();
  22.         World.setSize(10, 10);
  23.         World.showSpeedControl(true);
  24.         World.readWorld("Lesson4World1.kwld");
  25.  
  26.         Lesson4.Activity1 zgod = new Lesson4.Activity1(1, 3, North, -1);
  27.  
  28.         // calls the move method if the left is not clear. Otherwise, it backflips.Activity1
  29.         if (!zgod.leftIsClear()){
  30.             zgod.move();
  31.             zgod.move();
  32.             zgod.move();
  33.             zgod.move();
  34.         } else {
  35.             zgod.turnLeft();
  36.             zgod.turnLeft();
  37.         }
  38.     }
  39.  
  40.  
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement