Advertisement
Nalakava

Shelf Mover

Nov 2nd, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. import kareltherobot.UrRobot;
  2. import kareltherobot.World;
  3. import kareltherobot.Directions;
  4.  
  5.  
  6. //Class
  7. public class Shelf extends UrRobot
  8. {
  9.    //Define the robot
  10.    public Shelf(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("ShelfStocker.kwld");
  21.       World.showSpeedControl(true);
  22.       World.setTrace(false);
  23.       //create Shelf gary
  24.       Shelf gary = new Shelf (1,1,East,0);
  25.       gary.stockShelf();
  26.    }
  27.  
  28.     public void turnRight()
  29.    {
  30.         turnLeft();
  31.         turnLeft();
  32.         turnLeft();
  33.    }
  34.  
  35.    public void turnBack()
  36.    {
  37.     turnLeft();
  38.     turnLeft();
  39.    }
  40.  
  41.    public void goBack(){
  42.       turnBack();
  43.       move();
  44.       move();
  45.       move();
  46.       move();
  47.       move();
  48.       move();
  49.       move();
  50.       move();
  51.    }
  52.    
  53.    public void getShelf()
  54.    {
  55.     pickBeeper();
  56.     turnLeft();
  57.    }
  58.    
  59.    public void placeShelf()
  60.    {
  61.     move();
  62.     putBeeper();
  63.     turnBack();
  64.     move();
  65.     turnLeft();
  66.       move();
  67.    }
  68.    
  69.    public void moveShelf()
  70.    {
  71.     getShelf();
  72.     placeShelf();
  73.    }
  74.      
  75.    public void moveShelfBlock()
  76.    {
  77.     moveShelf();
  78.     moveShelf();
  79.     moveShelf();
  80.     moveShelf();
  81.    }
  82.      
  83.    public void stockShelf()
  84.    {
  85.       moveShelfBlock();
  86.       moveShelfBlock();
  87.       goBack();
  88.    }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement