Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // bobby does cardio program
- package Lesson3;
- import kareltherobot.*;
- public class Lesson3Activity1 extends UrRobot {
- public Lesson3Activity1(int x, int y, Direction d, int b) {
- super(x, y, d, b);
- }
- /**
- * robot turns right
- * @param
- * @return
- */
- public void turnRight() {
- int delay = World.delay();
- World.setDelay(0);
- turnLeft();
- turnLeft();
- World.setDelay(delay);
- turnLeft();
- }
- /**
- * robot moves up three times
- * @param
- * @return
- */
- public void moveUp() {
- move();
- move();
- move();
- }
- /**
- * robot is running up and down while picking up beepers
- * @param
- * @return
- */
- public void laneRunning () {
- moveUp();
- pickBeeper();
- turnRight();
- turnRight();
- moveUp();
- putBeeper();
- turnLeft();
- turnLeft();
- }
- /**
- * robot is switching lanes
- * @param
- * @return
- */
- public void switchLanes () {
- turnRight();
- move();
- turnLeft();
- }
- /**
- * robot does a full set of shuttle runs
- * @param
- * @return
- */
- public void runningAround () {
- laneRunning();
- laneRunning();
- laneRunning();
- laneRunning();
- laneRunning();
- }
- public static void main(String[] args) {
- Lesson3Activity1 bobby = new Lesson3Activity1(4, 3, North, 5);
- World.setDelay(10);
- World.setVisible();
- World.readWorld("Lesson3World1.kwld");
- bobby.runningAround();
- bobby.switchLanes();
- bobby.runningAround();
- bobby.switchLanes();
- bobby.runningAround();
- bobby.move();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement