Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Lesson3;
- //This is meant to go up the stairs and pick up beepers at each step to clear them
- import kareltherobot.UrRobot;
- import kareltherobot.World;
- public class Activity2Main extends UrRobot {
- public Activity2Main(int a, int s, Direction d, int b) {
- super(a, s, d, b);
- }
- public static void main(String[] args) {
- World.readWorld("Lesson3World2.kwld");
- World.setDelay(60);
- World.setVisible();
- Activity2Main gary = new Activity2Main(1, 1, North, 0);
- //Does the step 7 times since there are 7 steps on stairs
- for(int i = 0; i<7;i++){
- gary.riseUp();
- }
- }
- /**
- * Allows the robot to turn right
- * @ param - none
- * @ return - void
- */
- public void turnRight(){
- int delay = World.delay();
- World.setDelay(0);
- turnLeft();
- turnLeft();
- World.setDelay(delay);
- turnLeft();
- }
- /**
- * Allows robot to take a step on the stair and pick up a beeper
- * @ param - none
- * @ return - void
- */
- public void riseUp(){
- move();
- turnRight();
- move();
- pickBeeper();
- turnLeft();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement