Highlights
Task
Suzie in the Big City
Suzie is a mouse in the big city. She needs to collect a lot of cheese that will last her throughout the cold winter months. Each day, Suzie travels to a new city to gather up all the cheese crumbs she can find. Cheese crumbs are gathered in boxes, so Suzie has to open each box to steal the cheese. News of the cheese prowler has spread across neigbouring cities like wildfire. Concerned cities determined to protect their precious cheese have hired exterminators to take out the notorious Suzie. So she has to be extra careful now. Unbeknown to Suzie, exterminators now hide “traps” in some of these boxes, to trap Suzie when she opens it.
Your objective
Your goal is to lead Suzie to the cheese in these dangerous times.
Phase 1: The BigCity
A city is defined by an MxN grid (M may not be equal to N). The city will show the starting position of Suzie (denoted by s below). Suzie’s starting position is always at (0, 0).
The city will also show the boxes (denoted by ‘b’). Valid “paths” through the city are denoted by the ‘.’ character.
First create the city grid, named class BigCity.
The BigCity class should have:
cheesePositions) which creates a grid. It assigns the 2D array instance of cheese positions to the cheesePositions parameter passed.
This method should be called from the constructor you defined above.
Given the grid above, the constructor may be passed the following:
Given this sample input, you can tell that the box at (3, 4) contains a trap for the grid shown above, as it is not in the list of cheesePositions provided.
Phase 2: Loading BigCity from files
We want to be able to load a city from a file. The format is as follows:
For example:
6 5
s . . . .
. . b . .
. . . . .
b b . . .
. . . . b
. . . . .
4
2
3 0
1 2
is a valid file with a 6x5 city grid with 4 boxes and 2 cheese at locations (3, 0) and (1, 2).
To do this, add the following to your BigCity class:
This method should throw an IOException with an appropriate message if the data is not valid. Special exception messages include:
Your error messages should have as much detail as possible. See the sample output for what is expected.
Phase 3: Moving through BigCity
Add the following to enable moving along the city grid.
Create 2 count variables: one to track how many cheese crumbs Suzie has collected, and one to track how many moves Suzie has made moving through the grid. Do not forget to update both constructors to initialize them.
Create 1 boolean instance variable to indicate that Suzie is still loose and roaming the city.
Create a method void move(char direction). This will move Suzie in the direction specified. The following characters will represent the movements/direction along the grid
• ‘w’ - up
• ‘s’ - down
• ‘a’ - left
• ‘d’ - right
Throw appropriate IndexOutOfBoundsException for moving off the grid. If the move is valid, then process the move using the following helper method.
Create method private void processMove(char direction), which determines the next outcome of the game based on the direction from the move() method.
Update the grid to show Suzie’s movements. If she moves, replace her last position in the grid with ‘.’ and set the char at the new position to ‘s’. If Suzie collects a cheese, replace the ‘b’ with ‘s’ to show where she currently is. When she moves from that location, update the grid accordingly.
You may consider to create a method isBoxCheese(int row, int col) to check if the position (row, col) is one of the elements of the array cheesePositions. If yes, isBoxCheese returns true, otherwise, it returns false.
Phase 4: Game ending condition
Suzie has to keep scouring the city for boxes of cheese crumbs. She only stops when any of these happens:
To do this:
Create method private void endTerror(), that changes the value of the variable indicating that Suzie is still roaming the city.
Create a method boolean isRoamingCity() that tells the outside world if Suzie is still on the loose in the Big City!
Update the processMove method to check if the game is over, and calling endTerror to end the game.
Phase 5: Extracting data
First, create your own Exception type named DataDoesNotExistException. For this class, implement only a constructor that receives a String message. See a short tutorial about how to create a customized Exception here: https://www.baeldung.com/java-new-custom-exception. To implement DataDoesNotExistException, you likely need only 5 lines of simple codes.
Then, add two methods to your BigCity class:
Both methods should throw a DataDoesNotExistException when passed a row or column number that does not exist in your city grid.
Phase 6: Update the toString with Suzie’s stats!
When Suzie’s reign of terror is done in a Big City, update the output of your toString() method
to include one of the following on a new line. Optionally watch out for singular and plural tenses.
Sample output:
Suzie outsmarted the exterminators, making 5 moves and collecting all 2 cheese crumbs. She sniffed out the 3 traps.
Suzie outsmarted the exterminators, making 1 move and collecting all 1 cheese crumb. She sniffed out the 1 trap.
Suzie’s reign of terror came to an end abruptly after just 10 moves. She was captured with 0 cheese crumbs on her person.
Suzie’s reign of terror came to an end abruptly after just 2 moves. She was captured with 1 cheese crumb on her person.
Suzie’s reign of terror came to an end abruptly after just 1 move. She was captured with 0 cheese crumbs on her person.
Phase 7: Suzie’s Guardian Angel, Acqueline
Suzie’s guardian angel, Acqueline, is always watching out for her; she sees her every move and keeps track of them. Acqueline can only keep track of the last 5 moves Suzie makes. This enables Suzie go back in time a maximum of 5 steps at once.
To bring Acqueline to life, implement the following:
If there are elements in the partially-filled array, move them over to the right.
If the array is full and you need to insert at index 0, discard the last element in the array by moving the rest over to make room at index 0.
For example: consider adding values a, b, c, d, e, f to a char array in the same manner
Adding a: [a, , , , ] size: 1
Adding b: [b,a, , , ] size: 2
Adding c: [c,b,a, , ] size: 3
Adding d: [d,c,b,a, ] size: 4
Adding e: [e,d,c,b,a] size: 5
Adding f: [f,e,d,c,b] size: 5
If the partially-filled array is empty, it should do nothing.
When this is done, element 0 of the partially-filled array is removed, and the remaining 2D arrays must shuffle left to fill the space. Starting array: [f,e,d,c,b] size: 5
After undo: [e,d,c,b, ] size: 4
This COMP1020-IT Computer Science Assignment has been solved by our IT Computer Science Expert at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing Style. Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered.
You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turn tin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.