Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Language I need help with the following game, reading a maze text file and moving the mouse across it, InPutFile.txt m . . .

Java Language

I need help with the following game, reading a maze text file and moving the mouse across it,

InPutFile.txt

m . . . .

. . b . .

. . . . .

b b . . .

. . . . b

. . . . .

6 rows and 5 columns

4 -- boxes

2 ---- cheeses

(3, 0)- cheese position

(1 2)- cheese position

Create 2 count variables: one to track how many cheese crumbs Mouse has collected, and

one to track how many moves Mouse has made moving through the grid. Do not forget to

update both constructors to initialize them.

Create 1 boolean instance variable to indicate that Mouse is still loose and roaming the city.

Create a method void move(char direction). This will move Mouse in the direction

specified. The following characters will represent the movements along the grid

w - up

m - 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.

A move onto a valid path (.) increases the number of moves Mouse has made.

A move onto a b can either:

increase Mouses cheese collection by 1 (as well as her move count), or

end the game (and increase her move count) by calling the endTerror()

method you will implement in the next phase.

Update the grid to show Mouses movements. If she moves, replace her last position in the

grid with . and set the char at the new position to m. If Mouse collects a cheese, replace the

b with m to show

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

The Power Of Numbers In Health Care A Students Journey In Data Analysis

Authors: Kaiden

1st Edition

8119747887, 978-8119747887

More Books

Students also viewed these Databases questions

Question

Write Hund's rule?

Answered: 1 week ago