Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Activity2;
- import kareltherobot.*;
- /**
- * This program makes a robot walk forward until it finds the tower of beepers, and then climb it
- */
- public class Activity2Main extends Robot{
- public Activity2Main(int s, int a, Direction d, int b){
- super(s, a, d, b);
- }
- public static void main(String[] args){
- World.setVisible(); //generates world
- World.setDelay(35);
- World.readWorld("Lesson4World2.kwld");
- Activity2Main toad = new Activity2Main(1,1, East, 0);
- while(!toad.nextToABeeper()){ //while there aren't any beepers, keep walking
- toad.move();
- }
- toad.turnLeft();
- while(toad.nextToABeeper()){ //while there are beepers, keep walking
- toad.move();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement