Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Carlos Garcia
- Lesson 4 activity 2
- Stair Sweeper
- */
- package Lesson4;
- import kareltherobot.World;
- public class Activity2 extends EsperBot {
- public Activity2(int street, int avenue, Direction direction, int beeperCount) {
- super(street, avenue, direction, beeperCount);
- }
- public static void main(String[] args) {
- World.setDelay(5);
- World.setVisible();
- World.setSize(10, 10);
- World.showSpeedControl(true);
- World.readWorld("Lesson4World4.kwld");
- Activity2 zgod = new Activity2(1, 1, North, -1);
- zgod.sweep();
- }
- /**
- * Sweeps the entire staircase
- * @return void
- * */
- public void sweep() {
- while (inStair()) { //goes up a stair while there are stairs
- move();
- turnRight();
- move();
- while (nextToABeeper()) { //Picks beepers as long as there are beepers
- pickBeeper();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement