Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kareltherobot.UrRobot;
- import kareltherobot.World;
- import kareltherobot.Directions;
- //Class
- public class StairWalker extends UrRobot
- {
- //Define the robot
- public StairWalker(int street, int avenue, Direction direction, int beepers)
- {
- super(street, avenue, direction, beepers);
- }
- //Creation and actions of the robot
- public static void main (String[]args)
- {
- World.setVisible(true);
- World.readWorld("StairWalker.kwld");
- World.showSpeedControl(true);
- World.setTrace(false);
- //create StairWalker gary
- StairWalker gary = new StairWalker (1,1,East,0);
- gary.walkStair();
- }
- public void turnRight()
- {
- turnLeft();
- turnLeft();
- turnLeft();
- }
- public void climbCase()
- {
- turnLeft();
- move();
- turnRight();
- move();
- pickBeeper();
- }
- public void climbStair()
- {
- climbCase();
- climbCase();
- climbCase();
- }
- public void walk()
- {
- move();
- move();
- move();
- }
- public void fall()
- {
- move();
- turnRight();
- walk();
- }
- public void walkStair()
- {
- climbStair();
- fall();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment