Nalakava

Stair Walker

Nov 2nd, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. import kareltherobot.UrRobot;
  2. import kareltherobot.World;
  3. import kareltherobot.Directions;
  4.  
  5.  
  6. //Class
  7. public class StairWalker extends UrRobot
  8. {
  9.    //Define the robot
  10.    public StairWalker(int street, int avenue, Direction direction, int beepers)
  11.    {
  12.     super(street, avenue, direction, beepers);
  13.    }
  14.  
  15.  
  16.    //Creation and actions of the robot
  17.    public static void main (String[]args)
  18.    {
  19.       World.setVisible(true);
  20.       World.readWorld("StairWalker.kwld");
  21.       World.showSpeedControl(true);
  22.       World.setTrace(false);
  23.       //create StairWalker gary
  24.       StairWalker gary = new StairWalker (1,1,East,0);
  25.       gary.walkStair();
  26.    }
  27.          
  28.    public void turnRight()
  29.    {
  30.      turnLeft();
  31.      turnLeft();
  32.      turnLeft();
  33.    }
  34.    
  35.    public void climbCase()
  36.    {
  37.      turnLeft();
  38.      move();
  39.      turnRight();
  40.      move();
  41.      pickBeeper();
  42.    }
  43.    
  44.    public void climbStair()
  45.    {
  46.      climbCase();
  47.      climbCase();
  48.      climbCase();
  49.    }
  50.    
  51.    public void walk()
  52.    {
  53.      move();
  54.      move();
  55.      move();
  56.    }
  57.    
  58.    public void fall()
  59.    {
  60.      move();
  61.      turnRight();
  62.      walk();
  63.    }
  64.    
  65.    public void walkStair()
  66.    {
  67.     climbStair();
  68.      fall();
  69.    }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment