Advertisement
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 Shelf extends UrRobot
- {
- //Define the robot
- public Shelf(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("ShelfStocker.kwld");
- World.showSpeedControl(true);
- World.setTrace(false);
- //create Shelf gary
- Shelf gary = new Shelf (1,1,East,0);
- gary.stockShelf();
- }
- public void turnRight()
- {
- turnLeft();
- turnLeft();
- turnLeft();
- }
- public void turnBack()
- {
- turnLeft();
- turnLeft();
- }
- public void goBack(){
- turnBack();
- move();
- move();
- move();
- move();
- move();
- move();
- move();
- move();
- }
- public void getShelf()
- {
- pickBeeper();
- turnLeft();
- }
- public void placeShelf()
- {
- move();
- putBeeper();
- turnBack();
- move();
- turnLeft();
- move();
- }
- public void moveShelf()
- {
- getShelf();
- placeShelf();
- }
- public void moveShelfBlock()
- {
- moveShelf();
- moveShelf();
- moveShelf();
- moveShelf();
- }
- public void stockShelf()
- {
- moveShelfBlock();
- moveShelfBlock();
- goBack();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement