Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Karel will put 8 balls at each corner and continue.
- public class RacingKarel extends SuperKarel
- {
- public void run()
- {
- while (frontIsClear())
- {
- move();
- }
- while(frontIsBlocked())
- {
- for (int i=0; i < 8; i++)
- {
- putBall();
- }
- turnLeft();
- }
- while (frontIsClear())
- {
- move();
- }
- while(frontIsBlocked())
- {
- for (int i=0; i < 8; i++)
- {
- putBall();
- }
- turnLeft();
- }
- while (frontIsClear())
- {
- move();
- }
- while(frontIsBlocked())
- {
- for (int i=0; i < 8; i++)
- {
- putBall();
- }
- cactus();
- }
- while (frontIsClear())
- {
- move();
- }
- while(frontIsBlocked())
- {
- for (int i=0; i < 8; i++)
- {
- putBall();
- }
- potato();
- }
- }
- private void cactus()
- {
- turnLeft();
- }
- private void potato()
- {
- turnLeft();
- }
- }
Add Comment
Please, Sign In to add comment