Advertisement
KevinNT03

Karel Program - Altering the Original World

Oct 29th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. package Activity3;
  2. import kareltherobot.*;
  3.  
  4. public class Activity3Main implements Directions{
  5.     public static void main(String[] args) {
  6.         World.readWorld("Lesson1World2.kwld");
  7.         World.setVisible();
  8.         World.setDelay(60);
  9.  
  10.         UrRobot jimmy = new UrRobot(5, 1, North, 0);
  11.  
  12.         jimmy.turnLeft();
  13.         jimmy.turnLeft();
  14.         jimmy.turnLeft(); //the robot faces the structure
  15.         jimmy.move();
  16.         jimmy.move();     //it enters the structure
  17.         jimmy.pickBeeper();//it takes the beepers to reposition them
  18.         jimmy.move();
  19.         jimmy.pickBeeper();
  20.         jimmy.move();     //it doesn't take this one because it doesn't move
  21.         jimmy.move();
  22.         jimmy.pickBeeper();
  23.         jimmy.move();
  24.         jimmy.pickBeeper();
  25.         jimmy.turnLeft(); //robot took all beepers to be moved
  26.         jimmy.turnLeft();
  27.         jimmy.move();
  28.         jimmy.move();
  29.         jimmy.turnLeft();
  30.         jimmy.move();
  31.         jimmy.move();
  32.         jimmy.turnLeft();
  33.         jimmy.turnLeft();
  34.         jimmy.putBeeper(); //it starts placing the beepers in the desired place
  35.         jimmy.move();
  36.         jimmy.putBeeper();
  37.         jimmy.move();
  38.         jimmy.move();
  39.         jimmy.putBeeper();
  40.         jimmy.move();
  41.         jimmy.putBeeper();
  42.         jimmy.turnLeft(); //once it has put all the the beepers, it exits the structure
  43.         jimmy.turnLeft();
  44.         jimmy.move();
  45.         jimmy.move();
  46.         jimmy.turnLeft();
  47.         jimmy.turnLeft();
  48.         jimmy.turnLeft();
  49.         jimmy.move();
  50.         jimmy.move();
  51.         jimmy.move();
  52.         jimmy.move();    //back at the origin
  53.         jimmy.turnLeft();
  54.         jimmy.turnLeft();// back at facing North
  55.         jimmy.turnLeft();
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement