At the beginning of the game you should ask the user to enter the game mode in which they want to play the game using a dialogue box. CheeseWorld should be populated as specified in Table 1 according to the user choice.
Program CheeseWorld to add Barrel, Cheese, CheekyMouse, Home, LazyCat, MouseTrap objects as required.
Input validation: The only valid user choices are the values recorded in Table 1.
Notes:
- CheeseWorld is organised into an 8×8 grid cell. Each object appearing in the grid has a unique grid number and specific x coordinate and y coordinate value.
Add your pseudocode or flowchart for this task to the box.
Task 2: Program the CheekyMouse class
If CheekyMouse is not trapped, the user can move it one cell down, up, left or right with curser keys to find cheese.
If it is trapped, display a message in the console window indicating that it is trapped.
Sample message: CHEEKY MOUSE: Ouch, I’m trapped.
If CheekyMouse reaches its home:
- Make the mouse shout hooray.
- Stop the Greenfoot scenario.
- Display a message in the console window indicating the user wins the game.
- Display the count of cheese points the user collected in the console window.
The user can collect one cheese point for every piece of cheese eaten by the CheekyMouse.
Sample message:
CHEEKY MOUSE: Congratulations! You win the Game.
CHEEKY MOUSE: Total cheese points earned=A^
^ replaced by the number of cheese pieces eaten by the CheekyMouse.
Hints:
- You may use the methods given in Mouse Class.
- For the action, “it shouts hooray”, you should write your own method or, at a minimum, you should play the “hooray.wav”.
Add your pseudocode or flowchart for this task to the box.
Task 3: Program MouseTrap class
Catch the mouse if it steps into the trap.
If it is trapped,
- Stop the Greenfoot scenario.
- Display a message to the console window indicating in which cell number in the CheeseWorld grid this accident happened.
Sample message: MOUSE TRAP: CheekyMouse is trapped at grid cell xx*.
* xx replaced by the cell number.
Note: The grid numbering pattern is as follows.
Hints:
- You may use the methods given in MouseTrap Class to program the act() method.
- Use the getX() and getY() methods from Actor Class to find the x coordinate and y coordinate values of the MouseTrap to calculate the Grid number.
Add your pseudocode or flowchart for this task to the box.
Task 4: Program LazyCat
When the LazyCat is created in the CheeseWorld, it is in sleep status by default. However, LazyCat can be in one of two states (sleep/awake) during program execution.
Program the sleep behaviour of the LazyCat. You should display the sleeping cat image (use “small-cat-sleep-3.png”) and set the status to sleep.
Program the awake behaviour. You should display the image “small-cat.png” for the LazyCat. Set the status to awake.
If it is time to wake up, it wakes up. Make it perform a Mouse screening routine. Otherwise it is to go to sleep.
The CheekyMouse screening routine should be programmed as follows:
If it sees the CheekyMouse,
- Eat the Mouse.
- Dance##.
- Stop the Greenfoot scenario.
- Display a message to the console window indicating how many cheese it had saved.
Sample message: LAZY CAT: Game Over! No more hassle from CheekyMouse! Saved y** pieces of cheese.
** replaced by the number of Cheese objects left in the world.
The ##Dance routine in Lazy Cat dance consists of the following four steps.
Step 1: Hands in the air
Step 2: Flying
Step 3: Pointing up to the Right
Step 4: Pointing up to the Left.
LazyCat will perform the above four steps 4 times in this specific dance routine. Call the wait() method between each step.
Figure 4 gives the image name and image for each of the above steps.
“linus-song-loop.wav” should play in background during the dance performance.
Figure 4.1: Hands in the air | Figure 4.2: Flying | Figure 4.3: Pointing up to the Right | Figure 4.4: Pointing up to the Left |
small-cat-in-air.png | small-cat-fly.png | small-cat-dance-2.png | small-cat-dance.png |
Figure 4: Cat images for the dancing routine |
Add your pseudocode or flowchart for this task to the box.