Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KarelProgram extends Karel
- {
- public void run()
- {
- for(int i = 0; i < 20; i++)
- {
- invertBall();
- safeMove();
- }
- }
- private void invertBall()
- {
- if(noBallsPresent())
- {
- putBall();
- }
- else
- {
- takeBall();
- }
- }
- private void safeMove()
- {
- if(frontIsClear())
- {
- move();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement