Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- /**
- * @param x
- * @param y
- * @param d
- * @param b
- */
- public Lesson3Activity2(int x, int y, Direction d, int b){
- super(x, y, d, b);
- }
- /*
- Allows the robot to turn right to help his stepping process
- */
- public void turnRight(){
- int delay = World.delay();
- World.setDelay(0);
- turnLeft();
- turnLeft();
- turnLeft();
- World.setDelay(delay);
- }
- /*
- Makes the code for one single step so that this can be repeated
- */
- public void oneStep(){
- move();
- turnRight();
- move();
- pickBeeper();
- turnLeft();
- }
- /**
- This code allows for the world to be created, and for the robot to go up the steps.
- * @param args
- */
- public static void main(String[] args){
- World.setDelay(20);
- World.setVisible(); //Creates the world that the robot will live in.
- World.readWorld("Lesson3World2.kwld"); //Creates the world and the robot.
- Lesson3Activity2 roomba = new Lesson3Activity2(1, 1, North, 0);
- for (int index = 0; index < 7; index++){
- roomba.oneStep();
- }
- //Simple for loop so that each step repeats itself.
- }
- }
Add Comment
Please, Sign In to add comment