get Clara to create a checkerboard pattern of leaves inside an empty rectangular world (Figure 4.1),...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
X = {a,b,c,d. e, f} olmak zere (X.) ksmi sral kmesinin grafii aada verilmitir. (a) (X.) ksmi sral kmesinin maksimal, minimal, minimum ve maksimum elemanlarn belirtiniz. (b) (X.) kismi sral kmesinin Y...
-
If the central bank sets an exchange rate that undervalues the foreign currency- and the flows of goods and capital adjust simultaneously-what will be the impact on the following: (a) RFX...
-
Sketch the region bounded by the graphs of the equations and find the area of the region. f(x) = xe -x2 , y = 0, 0 x 1
-
Identify the most appropriate approach and then design. Provide a rationale as to why this approach and design would be most appropriate. Develop a hypothetical research scenario that would...
-
Balance Sheet Classification of Various Liabilities how would each of the following items be reported on the balance sheet? (a) Accrued vacation pay. (b) Estimated taxes payable. (c) Service...
-
If an employee's benefit is paid from a qualified plan in the form of a qualifying lump-sum benefit at retirement, the employee's cost basis will be recovered _______________ with an income tax...
-
1. Liam Richardson is the business manager for the Smith & Lyngate Insurance agencies in the state of Maryland. Liam is interested in increasing the number of agents in Baltimore and plans to buy...
-
Which of the following statements about the cost of capital is CORRECT ? Select one: a. Both the cost of debt and equity financing will decrease when a nuclear plant company encounters a ban on...
-
What is the importance of the pursuit and accumulation of wealth in the modern world? * What are some criticisms and concerns as they have been expressed over time and whether any of them bear...
-
Bob and Sally are both shareholders of XYZ Corporation. The annual shareholders' meeting is coming up, and they want to know how many "votes" they each have. What things must they look at to...
-
Analyze the following bill of exchange and provide responses to the questions following. All questions are specific to this bill of exchange. Drawn under documentary credit number Date March 17th...
-
Describe the changes in the administration of wealth ?
-
Describe how the Balanced Score Card helps Maverick Lodging achieves its value-added proposition. Be sure to explain in the first sentence Maverick Lodging's Value added proposition and how the...
-
Urinary System Anatomy - Practice on models 1. Name this structure that is the functional unit of the kidney. 2. Name the region that surrounds the apex of the renal pyramid. 6. 3. Name the region...
-
A statistical study shows that the fraction of television sets of a certain brand that are still in service after x years is given by f (x) = e-0.15x. (a) What fraction of the sets are still in...
-
If you need to determine the rate law, what methods would you use to collect the data and how would you analyze it?
-
The reversible gas-phase elementary reaction The chemical equation shows the formation of Ethyl benzene by the gas-phase reversible reaction of styrene and two molecules of hydrogen. Styrene (CH2...
-
Go to the LearnChemE screencast link for Chapter 17 (http://www.learncheme.com/screencasts/kinetics-reactor-design). View one of the screencast 5- to 6-minute video tutorials and list two of the most...
-
A circular shaft of radius \(r\) in the figure has a moment of inertia \(I\) and polar moment of inertia \(J\). The shaft is under torsion \(T_{z}\) in the positive zaxis and bending moment \(M_{x}\)...
-
A 20mm diameter rod made of a ductile material with a yield strength of \(350 \mathrm{MPa}\) is subject to a torque of \(T=100 \mathrm{~N} \cdot \mathrm{m}\) and a bending moment of \(M=150...
-
The figure below shows a round shaft of diameter \(1.5 \mathrm{in}\). loaded by a bending moment \(M_{z}\) \(=5,000 \mathrm{lb} \cdot\) in., a torque \(T=8,000 \mathrm{lb} . \cdot\) in., and an axial...
Study smarter with the SolutionInn App