seby_stephens

Lesson 2 Activity 3

Nov 5th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. package Lesson2;
  2. import kareltherobot.*;
  3.  
  4. public class Activity3Main implements Directions {
  5.  
  6.     public static void main(String[] args) {
  7.         World.readWorld("Lesson2World1.kwld");
  8.         World.setDelay(20);
  9.         World.setVisible();
  10.         //Declares robot object
  11.         UrRobot gary = new UrRobot(5, 3, North, -1);
  12.         //Makes robot face east
  13.         gary.turnLeft();
  14.         gary.turnLeft();
  15.         gary.turnLeft();
  16.         //Moves it around loop 5 times
  17.         for(int i = 0; i <5;i++){
  18.             //Moves it through half of the loop twice
  19.             for(int j = 0; j<2; j++) {
  20.                 gary.putBeeper();
  21.                 gary.move();
  22.                 gary.move();
  23.                 gary.move();
  24.                 gary.move();
  25.                 gary.putBeeper();
  26.                 gary.turnLeft();
  27.                 gary.move();
  28.                 gary.move();
  29.                 gary.turnLeft();
  30.             }
  31.  
  32.         }
  33.         //Moves robot to final spot once the loop is completed
  34.         gary.move();
  35.         gary.turnLeft();
  36.     }
  37. }
Add Comment
Please, Sign In to add comment