Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

get Clara to create a checkerboard pattern of leaves inside an empty rectangular world (Figure 4.1), and produce the world similar to what is

image text in transcribed image

get Clara to create a checkerboard pattern of leaves inside an empty rectangular world (Figure 4.1), and produce the world similar to what is shown in Figure 4.2. Figure 4.1. Initial screen Practical 5: Variables * * * * * * * * The length of the world is always an even number Clara always starts at the beginning of the first street (bottom) facing east * * * * Figure 4.2. Final Screen 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 with 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 produce the checkerboard pattern. 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. Instead of working with two streets at a time and reposition to east and west in-between, Clara must deal with one street at a time and then call the reposition() method. The reposition() method must make use of the variable you have created and to reposition west is Clara is facing east and reposition east if Clara is facing west. Which way she is facing should be determined using your variable. You can count on the following facts about Clara's World: Multiple worlds supplied with this problem will help you to ensure that your solution is generic and applies to many worlds. Practical 5: Variables Regular Problems In every practical, depending on your previous level of programming experience you have a choice to either complete a set of regular problems (if you are less experienced) or just to complete the Bonus problem and skip all the regular problems (if you are more experienced). A summary of marks for all regular problems is equal to the mark obtained for completing the bonus problem. If you want to maximise your chances of getting a high mark - you may consider completing all regular problems as well as the bonus problem. In this case mark deductions obtained in the regular problems can be compensated by the bonus problem. Note, however, that even if you produce no mistakes in all solutions - you can't obtain more than the maximum number of points allocated for all regular problems combined (10 points in this practical). 300580 Programming Fundamentals Week 6 Important Note Each of your solutions this week MUST declare and successfully use at least one variable to memorise certain facts about the world or Clara's progress. Correct use of variables is critical and your mark will be heavily dependent on this factor. Clara's vocabulary This week Clara can use the following commands turnLeft(); move(); putLeaf(); remove Leaf(); turnRight(); onLeaf(); treeFront(); treeLeft(); tree Right(); mushroomFront(); - Clara turns 90 degrees to the left - Clara moves one step forward in the direction she is currently facing - Clara puts one leaf at her current position - Clara removes a leaf at her current position - Clara turns 90 degrees to the right - Returns true if Clara is positioned on top of a leaf or false otherwise - Returns true if there is a tree one step ahead in the direction Clara faces or false otherwise - Returns true if there is a tree to the left from Clara or false otherwise - Returns true if there is a tree to the right from Clara or false otherwise - Returns true if there is a mushroom in front of Clara or false otherwise

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Elements Of Chemical Reaction Engineering

Authors: H. Fogler

6th Edition

013548622X, 978-0135486221

More Books

Students also viewed these Programming questions

Question

Distinguish between a rad and a rem?

Answered: 1 week ago

Question

Maintain five-figure accuracy

Answered: 1 week ago

Question

Maintain five-figure accuracy

Answered: 1 week ago