This site requires JavaScript, please enable it in your browser!
Greenfoot back
Ankitgujjar
Ankitgujjar wrote ...

2017/12/6

claraworld.net

Ankitgujjar Ankitgujjar

2017/12/6

#
This problem continues to test you in regards to code decomposition strategies, use of variables and possibly code modification. Clara’s task is to invert her world. This means putting a leaf in every empty cell and removing a leaf from every non-empty cell. While producing your solution for this problem you must use at least one variable (a good idea is to make this variable of type boolean). This variable should be used to help Clara in memorising the direction of her current movement. The simplest way to approach this problem is to base your solution around the sample code for ClaraCleaner from Lecture 3. But here, instead of cleaning the world you must invert it and you must make use of the variable that you declare in order to decide on whether to reposition Clara to the east or to the west, rather than looking at the trees around her to make this decision. Once you do it – make sure you clean up all the unnecessary code from the base solution. The initial configuration is shown in Figure 1 and the result should look similar to Figure 2. Figure 1 Figure 1. Figure 2 Figure 2. Clara always starts in the upper left corner facing east! Your program should be generic enough to handle any world configuration. Example worlds supplied with this problem will help you to test your code.
You need to login to post a reply.