In this problem you will learn how to use simple conditional statements. When you start the project, you will be presented with an empty field as shown in Figure 1. Your task is to make Clara move forward until she encounters a situation where both sides (left and right from Clara) are occupied by trees. Once Clara senses having trees on both sides – she must put a leaf at her current position, make a step forward and stop (as shown in Figure 2).

University/Course: WSU

Uploaded: October 27, 2024

Files: 1

✓ Solution:

/* PERMITTED COMMANDS
   move, stop, turnLeft, turnRight, treeLeft, treeRight, treeFront, onLeaf, putLeaf, removeLeaf, mushroomFront
   JAVA
   if, else, &&, ||, !
   To use this code in Greenfoot copy everything below to */
class MyClara extends Clara { 
/**
     * In the ‘act()’ function you can write your program for Clara 
     */
void act() {
// TODO: Write your code below
   move();

🔒 Whatsapp us for the full file.