Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. boolean checkBeeperStack(int x, int y, int numBeepers) {
  2. for(int i=0; i < y; ++i){
  3. moveRobotForwards();
  4. }
  5. turnRobotRight();
  6. for(int i=0; i < x; ++i){
  7. moveRobotForwards();
  8. }
  9.  
  10. if (countBeeperStack() == numBeepers){
  11. return true;
  12. }
  13. moveRobotBack();
  14. return false;
  15. }
  16.  
  17. void turnRobotRight(){
  18. turnRobotLeft();
  19. turnRobotLeft();
  20. turnRobotLeft();
  21. }
  22.  
  23. int countBeeperStack(){
  24. int counter = 0;
  25. while(isItemOnGroundAtRobot()){
  26. pickUpItemWithRobot();
  27. ++ counter;
  28. }
  29. return counter;
  30. }
  31.  
  32. void moveRobotBack(){
  33. turnRobotLeft();
  34. turnRobotLeft();
  35. while(isSpaceInFrontOfRobotClear()){
  36. moveRobotForwards();
  37. }
  38. turnRobotLeft();
  39. while(isSpaceInFrontOfRobotClear()){
  40. moveRobotForwards();
  41. }
  42. turnRobotLeft();
  43. turnRobotLeft();
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement