Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. /* PERMITTED COMMANDS
  2. move, turnLeft, turnRight, treeLeft, treeRight, treeFront, onLeaf, putLeaf, removeLeaf, mushroomFront
  3. JAVA
  4. if, while, for
  5.  
  6. To use this code in Greenfoot copy everything below to */
  7.  
  8. class MyClara extends Clara {
  9. /**
  10. * In the 'run()' function you can write your program for Clara
  11. */
  12. void run() {
  13. // TODO: Write your code below
  14.  
  15. boolean turnLeft = true;
  16. boolean leaf = false;
  17.  
  18. for (int y = 0; y < 8; y++) {
  19. for (int x = 0; x < 17; x++) {
  20. (leaf || y < 5) ? putLeaf() : "";
  21. leaf = !leaf;
  22. move();
  23. }
  24.  
  25. turnLeft ? turnLeft() : turnRight();
  26. (y < 5 || turnLeft) ? putLeaf() : "";
  27. move();
  28. turnLeft ? turnLeft() : turnRight();
  29. turnLeft = !turnLeft;
  30. }
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement