Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* PERMITTED COMMANDS
- move, turnLeft, turnRight, treeLeft, treeRight, treeFront, onLeaf, putLeaf, removeLeaf, mushroomFront
- JAVA
- if, while, for
- To use this code in Greenfoot copy everything below to */
- class MyClara extends Clara {
- /**
- * In the 'run()' function you can write your program for Clara
- */
- void run() {
- // TODO: Write your code below
- boolean turnLeft = true;
- boolean leaf = false;
- for (int y = 0; y < 8; y++) {
- for (int x = 0; x < 17; x++) {
- (leaf || y < 5) ? putLeaf() : "";
- leaf = !leaf;
- move();
- }
- turnLeft ? turnLeft() : turnRight();
- (y < 5 || turnLeft) ? putLeaf() : "";
- move();
- turnLeft ? turnLeft() : turnRight();
- turnLeft = !turnLeft;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement