Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import stanford.karel.*;
- public class HW2First extends SuperKarel{
- private void toNewspaper(){
- while(frontIsClear()){
- move();
- }
- turnRight();
- while(leftIsBlocked()){
- move();
- }
- turnLeft();
- move();
- }
- private void pickNewspaper(){
- pickBeeper();
- }
- private void backToHome(){
- turnAround();
- while(frontIsClear()){
- move();
- }
- turnRight();
- while(frontIsClear()){
- move();
- }
- turnRight();
- }
- public void run(){
- toNewspaper();
- pickNewspaper();
- backToHome();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement