Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Lesson2;
- import kareltherobot.*;
- public class Activity3Main implements Directions {
- public static void main(String[] args) {
- World.readWorld("Lesson2World1.kwld");
- World.setDelay(20);
- World.setVisible();
- //Declares robot object
- UrRobot gary = new UrRobot(5, 3, North, -1);
- //Makes robot face east
- gary.turnLeft();
- gary.turnLeft();
- gary.turnLeft();
- //Moves it around loop 5 times
- for(int i = 0; i <5;i++){
- //Moves it through half of the loop twice
- for(int j = 0; j<2; j++) {
- gary.putBeeper();
- gary.move();
- gary.move();
- gary.move();
- gary.move();
- gary.putBeeper();
- gary.turnLeft();
- gary.move();
- gary.move();
- gary.turnLeft();
- }
- }
- //Moves robot to final spot once the loop is completed
- gary.move();
- gary.turnLeft();
- }
- }
Add Comment
Please, Sign In to add comment