Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Carlos Garcia
- Lesson 4 Checkpoint 5
- Tower climbing
- */
- package Lesson4;
- import kareltherobot.World;
- public class Checkpoint5 extends EsperBot {
- public Checkpoint5(int street, int avenue, Direction direction, int beeperCount) {
- super(street, avenue, direction, beeperCount);
- }
- public static void main(String[] args) {
- World.setDelay(50);
- World.setVisible();
- World.setSize(10, 10);
- World.showSpeedControl(true);
- World.readWorld("Lesson4World2.kwld");
- Checkpoint5 zgod = new Checkpoint5(1, 1, East, -1);
- zgod.towerClimb();
- }
- /**
- * Function to find and climb the tower
- * @return void
- */
- public void towerClimb(){
- while (!nextToABeeper()) { //moves east until it finds the tower
- move();
- }
- turnLeft();
- while (nextToABeeper()) { //moves up as long as there are beepers
- move();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement