Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Carlos Garcia
- Lesson 4 Activity 1
- Left is Clear
- */
- package Lesson4;
- import kareltherobot.Robot;
- import kareltherobot.World;
- public class Activity1 extends EsperBot {
- public Activity1(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("Lesson4World1.kwld");
- Lesson4.Activity1 zgod = new Lesson4.Activity1(1, 3, North, -1);
- // calls the move method if the left is not clear. Otherwise, it backflips.Activity1
- if (!zgod.leftIsClear()){
- zgod.move();
- zgod.move();
- zgod.move();
- zgod.move();
- } else {
- zgod.turnLeft();
- zgod.turnLeft();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement