Advertisement
Guest User

Task2

a guest
Sep 17th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import stanford.karel.*;
  2.  
  3. public class Task2 extends Karel{
  4.    
  5.     private void turnRight(){
  6.         for(int i=0;i<3;i++){
  7.             turnLeft();        
  8.         }
  9.     }
  10.    
  11.     private void toNewspaper(){
  12.         for(int i=0;i<2;i++){
  13.             move();
  14.         }
  15.         turnRight();
  16.         move();
  17.         turnLeft();
  18.         move();    
  19.     }
  20.    
  21.     private void pickNewspaper(){
  22.         pickBeeper();
  23.     }
  24.    
  25.     private void backToHome(){
  26.         turnLeft();
  27.         turnLeft();
  28.         for(int i=0;i<3;i++){
  29.             move();
  30.         }
  31.         turnRight();
  32.         move();
  33.         turnRight();
  34.     }
  35.    
  36.     public void run(){
  37.         toNewspaper();
  38.         pickNewspaper();
  39.         backToHome();
  40.                        
  41.     }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement