Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Activity2;
- import kareltherobot.*;
- public class Activity2Main extends UrRobot{
- public Activity2Main (int s, int a, Direction d, int b){
- super(s, a, d, b);
- }
- public static void main(String[] args) {
- World.readWorld("Lesson3World2.kwld"); //reading and creating world
- World.setVisible();
- World.setDelay(25);
- Activity2Main kratos = new Activity2Main(1,1, North, 0);
- for(int i = 0; i < 4; i++){ //robot spins in place to give the program time to load
- kratos.turnLeft();
- }
- for(int y = 0; y < 7; y++){ //loop executes seven times - seven steps
- kratos.climbStep();
- kratos.pickBeeper();
- }
- }
- /**
- * The robot climbs one step up
- * @param - none
- * @return - none
- */
- public void climbStep(){
- move();
- turnRight();
- move();
- turnLeft();
- }
- /**
- * allows the robot to instantaneously turn right
- * @param - none
- * @return - none
- */
- public void turnRight(){
- int delay = World.delay();
- World.setDelay(0);
- turnLeft();
- turnLeft();
- World.setDelay(delay);
- turnLeft();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement