1.3.4: Tower Karel, 1.3.5: Gold Medal Karel, 1.3.6: Maze Karel
Code for these lessons:
1.3.4: Tower Karel
- move();
- turnLeft();
- putBall();
- move();
- putBall();
- move();
- putBall();
- move();
- turnLeft();
- turnLeft();
- turnLeft();
1.3.5: Gold Medal Karel
- move();
- putBall();
- move();
- putBall();
- move();
- putBall();
- turnLeft();
- move();
- turnLeft();
- move();
- putBall();
- turnLeft();
- turnLeft();
- turnLeft();
- move();
- turnLeft();
- turnLeft();
- turnLeft();
1.3.6: Maze Karel
- while(frontIsClear()){
- move();
- if(frontIsBlocked()){
- turnLeft();
- }
- }
- turnLeft();
- turnLeft();
- while(frontIsClear()){
- move();
- if(frontIsBlocked()){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- if(frontIsBlocked()){
- turnLeft();
- }
- while(frontIsClear()){
- move();
- if(frontIsBlocked()){
- turnLeft();
- turnLeft();
- turnLeft();
- }
- if(frontIsBlocked()){
- turnLeft();
- turnLeft();
- }
- }
- }
- turnLeft();
- turnLeft();
- turnLeft();
Comments
Post a Comment