Advertisement
GARC923

L4A2

Oct 21st, 2022
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. /**
  2. Carlos Garcia
  3. Lesson 4 activity 2
  4. Stair Sweeper
  5. */
  6.  
  7. package Lesson4;
  8.  
  9. import kareltherobot.World;
  10.  
  11.  
  12. public class Activity2 extends EsperBot {
  13.     public Activity2(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(5);
  20.         World.setVisible();
  21.         World.setSize(10, 10);
  22.         World.showSpeedControl(true);
  23.         World.readWorld("Lesson4World4.kwld");
  24.  
  25.         Activity2 zgod = new Activity2(1, 1, North, -1);
  26.  
  27.         zgod.sweep();
  28.     }
  29.  
  30.     /**
  31.      * Sweeps the entire staircase
  32.      * @return void
  33.      * */
  34.     public void sweep() {
  35.         while (inStair()) { //goes up a stair while there are stairs
  36.             move();
  37.             turnRight();
  38.             move();
  39.             while (nextToABeeper()) { //Picks beepers as long as there are beepers
  40.                 pickBeeper();
  41.             }
  42.         }
  43.     }
  44.  
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement