Advertisement
KevinNT03

Karel Program - Creating 10 stacks of 100 beepers

Nov 5th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. package Activity2;
  2. import kareltherobot.*;
  3.  
  4. public class Activity2Main implements Directions{
  5.  
  6.     public static void main(String[] args) {
  7.  
  8.         World.setVisible();
  9.         World.setDelay(2); //low delay because of the large amount of beepers
  10.  
  11.         UrRobot johnny = new UrRobot(5,1, East,1000);
  12.  
  13.         for(int temp = 0; temp < 20; temp++){ //spins in place to give the program time to load
  14.             johnny.turnLeft();
  15.         }
  16.  
  17.         for(int out = 0; out < 10; out++){   //loop runs inner loop 10 times and moves forward each time
  18.             for(int in = 0; in < 100; in++){ //loop puts 100 beepers
  19.                 johnny.putBeeper();
  20.             }
  21.             johnny.move();
  22.         }
  23.  
  24.         johnny.turnLeft(); //moves so we can see beepers
  25.         johnny.move();
  26.         johnny.turnLeft();
  27.  
  28.         for(int i = 0; i < 10; i++){ //robot moves back to the left of the map
  29.             johnny.move();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement