Advertisement
GARC923

L4CH5

Oct 21st, 2022
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. /**
  2. Carlos Garcia
  3. Lesson 4 Checkpoint 5
  4. Tower climbing
  5. */
  6.  
  7. package Lesson4;
  8.  
  9. import kareltherobot.World;
  10.  
  11.  
  12. public class Checkpoint5 extends EsperBot {
  13.     public Checkpoint5(int street, int avenue, Direction direction, int beeperCount) {
  14.         super(street, avenue, direction, beeperCount);
  15.     }
  16.  
  17.  
  18.     public static void main(String[] args) {
  19.         World.setDelay(50);
  20.         World.setVisible();
  21.         World.setSize(10, 10);
  22.         World.showSpeedControl(true);
  23.         World.readWorld("Lesson4World2.kwld");
  24.  
  25.         Checkpoint5 zgod = new Checkpoint5(1, 1, East, -1);
  26.  
  27.         zgod.towerClimb();
  28.     }
  29.  
  30.     /**
  31.      * Function to find and climb the tower
  32.      * @return void
  33.      */
  34.     public void towerClimb(){
  35.         while (!nextToABeeper()) { //moves east until it finds the tower
  36.             move();
  37.         }
  38.         turnLeft();
  39.         while (nextToABeeper()) { //moves up as long as there are beepers
  40.             move();
  41.         }
  42.     }
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement