Advertisement
Guest User

kevin is a fucking fag-bitch

a guest
Sep 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.40 KB | None | 0 0
  1. 1.16.4
  2.  
  3. public class SuperCleanupKarel extends SuperKarel{
  4.     public void run(){
  5.         faceNorth();
  6.         while(frontIsClear()){
  7.             cleanRow();
  8.             faceNorth();
  9.             move();
  10.         }
  11.         cleanRow();
  12.     }
  13.     private void faceNorth(){
  14.         while(notFacingNorth()){
  15.             turnLeft();
  16.         }
  17.     }
  18.     private void faceEast(){
  19.         while(notFacingEast()){
  20.             turnLeft();
  21.         }
  22.     }
  23.     private void cleanRow(){
  24.         faceEast();
  25.         if(frontIsClear()){
  26.             while(frontIsClear()){
  27.                 if(ballsPresent()){
  28.                     takeBall();
  29.                 }
  30.                 move();
  31.             }
  32.             if(ballsPresent()){
  33.                 takeBall();
  34.             }
  35.         }
  36.         else{
  37.             turnAround();
  38.             if(frontIsClear()){
  39.             while(frontIsClear()){
  40.                 if(ballsPresent()){
  41.                     takeBall();
  42.                 }
  43.                 move();
  44.                 }
  45.             }
  46.             if(ballsPresent()){
  47.                 takeBall();
  48.             }
  49.         }
  50.     }
  51. }
  52.  
  53. 1.16.5
  54.  
  55. public class DoubleTennisBallsKarel extends SuperKarel
  56. {
  57.     public void run()
  58.     {
  59.         move();
  60.         while(ballsPresent()){
  61.             takeBall();
  62.             turnLeft();
  63.             move();
  64.             turnRight();turnRight();
  65.             putBall();
  66.             move();
  67.             turnLeft();
  68.         }
  69.         turnLeft();
  70.         move();
  71.         turnRight();
  72.         while(ballsPresent()){
  73.             takeBall();
  74.             turnRight();
  75.             move();
  76.             putBall();putBall();
  77.             turnAround();
  78.             move();
  79.             turnRight();
  80.         }
  81.         turnAround();
  82.         move();
  83.         turnLeft();
  84.         move();
  85.         turnLeft();
  86.     }
  87. }
  88.  
  89. 1.16.5
  90.  
  91. public class MidpointKarel extends SuperKarel
  92. {
  93.     public void run()
  94.     {
  95.         turnLeft();
  96.         while(frontIsClear()){
  97.             move();
  98.         }
  99.         turnAround();
  100.         while(frontIsClear()){
  101.             move();
  102.             if(frontIsClear()){
  103.                 move();
  104.             }
  105.             else{
  106.                 break;
  107.             }
  108.             turnLeft();
  109.             if(frontIsClear()){
  110.                 move();
  111.             }
  112.             turnRight();
  113.         }
  114.         putBall();
  115.         turnLeft();
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement