Advertisement
KevinNT03

Karel Program - Put 1000 Beepers in the Same Place

Nov 5th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package Activity1;
  2. import kareltherobot.*;
  3.  
  4. public class Activity1Main implements Directions{
  5.  
  6.     public static void main(String[] args) {
  7.  
  8.         World.setVisible(); //creates world
  9.         World.setDelay(2);  //small delay because it has to put 1000 beepers
  10.  
  11.         UrRobot geralt = new UrRobot(1,1, North, 1000); //creates robot
  12.  
  13.         for(int x = 0; x < 19; x++){ //spins in place to give the program time to load
  14.             geralt.turnLeft();
  15.         }
  16.  
  17.         geralt.move(); //moves away from the origin to put the beepers
  18.  
  19.         for(int i = 0; i < 1000; i++){ //loop puts 1000 beepers in the same place
  20.             geralt.putBeeper();
  21.         }
  22.  
  23.         geralt.turnLeft(); //moves away from beepers so we can see them
  24.         geralt.turnLeft();
  25.         geralt.move();
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement