Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Java program will respond to the following commands: * Direction commands –

ID: 3887226 • Letter: T

Question

The Java program will respond to the following commands:

* Direction commands – Make the “go” optional

* Look command – Displays the description of the location

* Quit command

When the player moves to a new location, automatically invoke the look command. Of course the player can always use the look command when he or she needs to. The following is one possible output:

Zeta – The Ultimate Adventure Game

You see a house with a pat leading north to a forest and a path leading east to a beach. There is a axe, pot, and cat laying here.

>>north

You are in a dark forest. A path leads south and east.

>>west

I don’t know how to do that!

>>east

A wide cold river flows here. A path leads to the west and south. There is a boat laying here.

>>look

A wide cold river flows here. A path leads to the west and south. There is a boat laying here.

>>south

A black sand beach lies before you. The lake is down and a path leads west.

>>down

You drowned.

>>up

A black sand beach lies before you. The lake is down and a path leads west.

>>east

I don’t know how to do that!

>>west

You see a house a house with a path leading north to a forest and a path leading east to a beach. There is a axe, pot, and cat laying here.

>>quit

Game over!

Device a data structure that represents a location (node) and includes at minimum:

* Name

* Description

* List of direction possible from this location (adjacency list) Do not hardcode the directions!

* List of items at that location

Use a second data type to hold the game’s locations. One way of maintaining these locations is to use an array. When a user wants to move from one location to another, you can check to see if that location exists. Using a currentLocation index to the array will maintain your position in the game.

If you are using Java, a better approach is to use a HashTable to hold all of the locations in your game. You can use the put method to add nodes with a key. The key can be the name of the location. The get method can return a specific node.

For list of things, such as items at a location, use an ArrayList

Store all of your location information in a file. During the program initialization, read this file, create the individual nodes, and then add them to your game location data structure.

Explanation / Answer

the "locationnodes.txt" sample file is, each location is in next line:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote