In problem 3 your task is to make Clara move through the middle row in the world shown in Figure 1. and place a leaf in any cell that has a tree either above or below this cell. Clara has to stop when she detects that there is a tree in front of her. The result should look similar to Figure 2. Starting from this problem, there will be restrictions on commands that you can use in your solutions. Those restrictions will appear at the top of MyClara file as shown in Figure 3. In this problem you are only allowed to use commands shown in Figure 3. Notice that you are not allowed to use turnLeft() and turnRight() commands. Your solution must be generic and has to work with all supplied example worlds. This means that before submitting you must test your code with all supplied worlds and it must correctly work in all of those. You should also aim at making sure that the code would work with all similar worlds with similar properties (beyond the provided examples).

University/Course: WSU

Uploaded: November 2, 2024

Files: 1

✓ Solution:

/* PERMITTED COMMANDS
   move(); treeLeft(); treeRight(); treeFront(); onLeaf(); putLeaf(); removeLeaf(); stop();
   JAVA
   if, else, &&, ||, ! */
   
class MyClara extends Clara { 
    /**
     * In the ‘act()’ method you can write your program for Clara 
     */
    void act() {
        // TODO: Write your code below
   if(treeLeft()||treeRight())

🔒 Whatsapp us for the full file.