Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Activity3;
- import kareltherobot.*;
- public class Activity3Main implements Directions{
- public static void main(String[] args) {
- World.readWorld("Lesson1World2.kwld");
- World.setVisible();
- World.setDelay(60);
- UrRobot jimmy = new UrRobot(5, 1, North, 0);
- jimmy.turnLeft();
- jimmy.turnLeft();
- jimmy.turnLeft(); //the robot faces the structure
- jimmy.move();
- jimmy.move(); //it enters the structure
- jimmy.pickBeeper();//it takes the beepers to reposition them
- jimmy.move();
- jimmy.pickBeeper();
- jimmy.move(); //it doesn't take this one because it doesn't move
- jimmy.move();
- jimmy.pickBeeper();
- jimmy.move();
- jimmy.pickBeeper();
- jimmy.turnLeft(); //robot took all beepers to be moved
- jimmy.turnLeft();
- jimmy.move();
- jimmy.move();
- jimmy.turnLeft();
- jimmy.move();
- jimmy.move();
- jimmy.turnLeft();
- jimmy.turnLeft();
- jimmy.putBeeper(); //it starts placing the beepers in the desired place
- jimmy.move();
- jimmy.putBeeper();
- jimmy.move();
- jimmy.move();
- jimmy.putBeeper();
- jimmy.move();
- jimmy.putBeeper();
- jimmy.turnLeft(); //once it has put all the the beepers, it exits the structure
- jimmy.turnLeft();
- jimmy.move();
- jimmy.move();
- jimmy.turnLeft();
- jimmy.turnLeft();
- jimmy.turnLeft();
- jimmy.move();
- jimmy.move();
- jimmy.move();
- jimmy.move(); //back at the origin
- jimmy.turnLeft();
- jimmy.turnLeft();// back at facing North
- jimmy.turnLeft();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement