Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. public class OrdnungMussSein extends BouncerApp {
  2.  
  3. @Override
  4. public void bounce() {
  5. loadMap("Cleanup");
  6. cleanThemAll();
  7. }
  8.  
  9.  
  10. private void cleanThemAll () {
  11. for (int i=0; i < 8; i++) {
  12. walkingRight();
  13. walkingLeft();
  14. }
  15. }
  16.  
  17. /*Method: walking
  18. **
  19. * Combines the searching task with changing of search-row
  20. */
  21. private void walkingRight() {
  22. searchingAndCleaningRight();
  23. changeLineRight();
  24. }
  25.  
  26.  
  27. private void walkingLeft() {
  28. searchingAndCleaningLeft();
  29. changeLineLeft();
  30. }
  31.  
  32.  
  33. /*Method: searchingAndCleaning
  34. **
  35. * Cleans the red tiles while moving through the lines
  36. */
  37. private void searchingAndCleaningRight () {
  38. while (bouncer.canMoveForward()) {
  39. redToWhite();
  40. bouncer.move();
  41. }
  42. }
  43.  
  44.  
  45. private void searchingAndCleaningLeft () {
  46. while (bouncer.canMoveForward()) {
  47. redToWhite();
  48. bouncer.move();
  49. }
  50. }
  51.  
  52.  
  53. /*Method: changeLine
  54. **
  55. * Changes the line which bouncer searches for red tiles.
  56. */
  57. private void changeLineRight() {
  58. while (bouncer.canNotMoveForward()) {
  59. turningRight();
  60. bouncer.move();
  61. if (bouncer.canNotMoveLeft()) {
  62. turningRight();
  63. }
  64. else {
  65. passingHurdlesRight();
  66. while (bouncer.canMoveForward()) {
  67. bouncer.move();
  68. redToWhite();
  69. }
  70. }
  71. redToWhite();
  72. }
  73. }
  74.  
  75.  
  76. private void changeLineLeft(){
  77. while (bouncer.canNotMoveForward()){
  78. bouncer.turnLeft();
  79. bouncer.move();
  80. if (bouncer.canNotMoveRight()) {
  81. bouncer.turnLeft();
  82. }
  83. else {
  84. passingHurdlesLeft();
  85. while (bouncer.canMoveForward()) {
  86. bouncer.move();
  87. redToWhite();
  88. }
  89. }
  90. redToWhite();
  91. }
  92.  
  93. }
  94.  
  95.  
  96. /*Method: passingHurdlesRight
  97. **
  98. * Allows bouncer to pass obstacles coming from the left.
  99. */
  100. private void passingHurdlesRight () {
  101. bouncer.turnLeft();
  102. bouncer.move();
  103. bouncer.move();
  104. bouncer.turnLeft();
  105. bouncer.move();
  106. turningRight();
  107. }
  108.  
  109.  
  110. /*Method: passingHurdlesRight
  111. **
  112. * Allows bouncer to pass obstacles coming from the right.
  113. */
  114. private void passingHurdlesLeft () {
  115. turningRight();
  116. bouncer.move();
  117. bouncer.move();
  118. turningRight();
  119. bouncer.move();
  120. bouncer.turnLeft();
  121. }
  122.  
  123.  
  124. /*Method: turningRight
  125. **
  126. * Turns bouncer three times. Can be used to turn him to the right side.
  127. */
  128. private void turningRight (){
  129. for (int i=0; i < 3; i++){
  130. bouncer.turnLeft();}
  131. }
  132.  
  133.  
  134. /*Method: redToWhite
  135. **
  136. * Turns red fields into white ones.
  137. */
  138. private void redToWhite () {
  139. if (bouncer.isOnFieldWithColor(FieldColor.RED)) {
  140. bouncer.paintField(FieldColor.WHITE);
  141. }
  142. }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement