Advertisement
Guest User

Karel: Unit 9, Lesson 2

a guest
May 28th, 2015
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. //Karel must help rebuild
  2. //broken columns. Make a
  3. //column of beepers above
  4. //each beeper you find on
  5. //the first row
  6. function main() {
  7.    while(frontIsClear()){
  8.       checkNPlace();
  9.       move();
  10.    }
  11. }
  12.  
  13. function checkNPlace(){
  14.    if(beepersPresent()){
  15.       turnLeft();
  16.       while(frontIsClear()){
  17.          move();
  18.          putBeeper();
  19.       }
  20.       turnAround();
  21.       while(frontIsClear()){
  22.          move();
  23.       }
  24.       turnLeft();
  25.    }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement