Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Lesson3;
- import kareltherobot.*;
- public class Lesson3Activity2 extends UrRobot{
- //constructor from UrRobot for my alphabot
- public Lesson3Activity2(int x, int y, Direction d, int b) {
- super(x, y, d, b);
- }
- public static void main(String[] args) {
- World.readWorld("Lesson3World2.kwld");
- World.setDelay(30);
- World.setVisible();
- Lesson3Activity2 alphaBot = new Lesson3Activity2(1,1,North, 0);
- //climbs the steps 7 times
- for(int i = 0; i < 7; i++) {
- alphaBot.stairClimb();
- }
- }
- /**
- * makes the robot climb one staircase
- * @param
- * @return void
- */
- public void stairClimb() {
- move();
- turnRight();
- move();
- pickBeeper();
- turnLeft();
- }
- /**
- * makes robot appear to turn right
- * @param
- * @return void
- */
- public void turnRight() {
- //changing the delay to 0
- int delay = World.delay();
- World.setDelay(0);
- turnLeft();
- turnLeft();
- //setting the relay to what it was previously set to
- World.setDelay(delay);
- turnLeft();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement