Exemple #1
0
 public void doIt(UrRobot arobot) {
   arobot.move();
   arobot.putBeeper(); // beeper 1
   arobot.move();
   arobot.putBeeper(); // beeper 2
   arobot.turnLeft();
 }
Exemple #2
0
 public static void main(String[] args) {
   World.setVisible(true); // makes world visible
   World.setDelay(10); // speed of world is 10
   UrRobot karel = new UrRobot(1, 1, East, 0); // new robot named karel
   UrRobot sarah = new UrRobot(3, 2, East, 0);
   squareDance(sarah);
   squareDance(karel);
   sarah.turnOff();
   karel.turnOff();
 }
Exemple #3
0
 public static void squareDance(UrRobot robot) // robot can be any robot created in main
     {
   for (int turns = 0; turns < 5; turns++) // instructions for each side, repeated 5 times
   {
     for (int stepstaken = 0; stepstaken < 3; stepstaken++) // take 2 steps
     {
       robot.move();
     }
     if (turns != 4) // if done first 4 sides don't turn
     {
       robot.turnLeft();
     } else ;
   }
 }