Facebook
From Matthew Sola, 3 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 54
  1. package Lesson2;
  2.  
  3. import kareltherobot.*;
  4.  
  5. public class Activity2 implements Directions
  6. {
  7.     public static void main(String[] args)
  8.     {
  9.         World.setDelay(1);
  10.         World.setVisible();
  11.  
  12.         UrRobot alphaBot = new UrRobot(1,1,North,1000); //Starts at the origin
  13.  
  14.         for(int runs = 0; runs< 10; runs++) //Makes 10 stacks
  15.         {
  16.             for(int index = 0; index<100; index++) // Puts 100 beepers
  17.             {
  18.                 alphaBot.putBeeper();
  19.             }
  20.             if (runs < 9) //Prevents Karel from moving off the screen
  21.             {
  22.                 alphaBot.move();
  23.             }
  24.         }
  25.         for(int y = 0; y < 3; y++)
  26.         {
  27.             alphaBot.turnLeft();  //turns the robot 90 degrees to the right
  28.         }
  29.         alphaBot.move();
  30.     }
  31. }
  32.