Reference no: EM132852517
300580 Programming Fundamentals - Western Sydney University
Problem Decomposition
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).
Problem 1 - Playing Mini Pacman
In this problem Clara plays a simplified version of the Pacman game. She is positioned on top of the first of a long trail of leaves, ending in front of a tree (as shown in Figure 1.1). She must pick up all leaves and stop in front of the first tree she encounters (as shown in Figure 1.2).
The most important characteristics of your solution are:
• There must be no leaves after program stops running.
• Leaves must be removed in correct order starting with the leaf under Clara and ending with the leaf next to a tree.

Figure 1.1. Initial screen Figure 1.2. Final Screen
Your program should be generic enough to handle any combination of leaves located next to one another in any configuration. Example worlds supplied with this problem will help you to test your code.
Problem 2 - Fix Leaf Trail
Clara is interested in ancient Greek mythology. She has read a story about Theseus and Minotaur and decided to replicate it in her world. According to the original story, Theseus finds a way out of a labyrinth by using a ball of red thread that Theseus unrolled as he penetrated the labyrinth, which allowed him to find his way back out. You can read more about Theseus and Minotaur.
In Clara's world the labyrinth looks similar to Figure 2.1. Instead of unrolling the thread Clara must put leaves everywhere she goes as she is looking for a way out.
Unfortunately, there are some leaves that are already present in the labyrinth. Clara must ignore those and simply place the leaves in all cells on her path where no leaves are present.

Figure 2.1. Initial screen Figure 2.2. Final Screen
In the labyrinth there is always a mushroom that represents the exit. Clara's objective is to walk to the mushroom and stop in front of it. Her way from the initial position to the mushroom must be marked with leaves as shown in Figure 2.2.
The labyrinth is always of such a kind that Clara is able to get to the mushroom by simply walking forward until she encounters a tree in front of her that blocks her way. When there is a tree blocking her way, she should turn left and continue walking. She would know that her objective is completed when Clara discovers that she is positioned in front of a mushroom ( mushroomFront() ). The result of executing your code should look similar to Figure 2.2.
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).
Problem 3 - Fixing Columns
Clara's world has been shattered by an earthquake and to avoid any further damage she must quickly repair it. In particular, Clara is to repair a set of arches where some of the stones (represented by leaves, of course) are missing from the columns supporting the arches, as shown in Figure 3.1.
Your program should work on the world shown in Figure 3.1, but it should be generic enough to handle any world that meets certain basic conditions as outlined at the end of this problem. There are several example worlds in the starter folder, and your program should work correctly with all of them.
When Clara is done, the missing stones in the columns should be replaced by leaves, so that the final picture resulting from the world shown above would look like Figure 3.2.
It is extremely important for this problem to only use the permitted commands as described in the header of the main file (MyClara.java). It is explicitly prohibited to use treeFront(), treeLeft() and treeRight() methods.

Figure 3.1. Initial screen Figure 3.2. Final Screen
Clara may count on the following facts about the world:
• Clara starts at 1st Avenue and 1st Street, facing east, with an infinite number of leaves in her bag.
• The columns are exactly four units apart, on 1st, 5th, 9th avenue, and so forth.
• All columns are of the same height and are always exactly 7 units tall.
• Some of the corners in the column may already contain leaves representing stones that are still in place. Your program should not put a second leaf on these corners.
• Towards the end of the first street and immediately to the right of the last column there is always a mushroom that can be sensed using mushroomFront() method.
As usual, your code must be generic to deal with all supplied example worlds.
Bonus Problem
If you had previous programming experience - it is advisable to start with the bonus problem and see whether you can complete it. Students who didn't have prior programming experience should only attempt the bonus problem after completing the regular problems.
Problem 4 - Divide by Two
Clara starts in the world with a certain number of leaves randomly placed around the world as shown in Figure 4.1.
For every street in her world (if we assume that the number of leaves on this street is n) Clara must produce n/2 number of leaves on this street as shown in Figure 4.2. If the number of leaves on the street (n) happens to be an odd number, then Clara must round up the result to the nearest integer.
For example, if there were 5 leaves on some street originally then Clara must not produce 5/2 = 2.5 leaves (as she is unable to produce half a leaf), instead she must produce 3 leaves on this street.
It is important to have the correct number of leaves on every street, but their locations are not important.

Figure 4.1. Initial screen Figure 4.2. Final Screen
IMPORTANT: You are explicitly prohibited to use for loops and variables for solving this problem.
Your solution must be generic and must work with all supplied example worlds. It should also work with any world of any size and any number of leaves on any street placed in any desired order. A good way to test that your solution is generic is to randomly shuffle the leaves around in the example worlds and run your code a few times with various combinations of leaves positioned at different streets and make sure it works correctly in every such world.
Attachment:- Programming Fundamentals.rar