Purpose: This problem emphasizes the design and coding of an object-oriented application using multiple arrays, classes, and methods. Sequence, selection, and iteration logic are also used, as are logical program blocks, input/output dialogs, and the object-messaging model.

Problem: The Great Cal Poly Underground exists as a network of rooms on a two-dimensional array. Each room provides a virtual environment that together can be assembled into a simulated world. The ability to manipulate virtual environments is fast becoming a central element in business simulations. In this project, you will construct the GCPU using the Java programming language. Details are provided in the following sections.

Map of the Great Cal Poly Underground. see image.

Add 7 more university- themed rooms of your own choosing in any of the blank spaces to the left.

Add exits as appropriate to any existing rooms, but do not modify existing exits.

General Discussion

This project is a composition of classes: (1) Map used to control instantiation and initial placement of the rooms and their contents, (2) Room responsible for providing the characteristics and behavior for each room instance placed on the map, (3) Artifact representing items placed within rooms, (4) SpecialArtifact that switch state from off to on and back by responding to touch commands, and (5) an application class to start the program and handle the user dialog.

In its initial configuration, the program begins by creating a two-dimensional map containing 4 x 4 cells, with each cell capable of holding a single room instance. Rooms are then instantiated (along with any artifacts contained therein) with the resulting instances being located on the map according to the diagram provided above.

Input and Output

Your program must accept the input shown below using the system console. Note that all inputs are case insensitive. All output should be displayed to the console window.

Possible Valid Movements:

n = north, s = south, e = east, w = west, nw = northwest, sw = southwest, ne = northeast, se = southeast

Other:

look, examine, touch, quit

look - Display name, description, exits of room, and name of any artifact present. If no artifact is present, say the room is empty.

examine - Display details of any artifact present. If none, say there is nothing to examine or similar message.

touch - Changes state of artifact, when applicable, and returns corresponding message. If none, say there is nothing to touch.

quit - Prompt to terminate the program (see sample dialog for appropriate message).

Response to Invalid Inputs:

An inappropriate, but otherwise valid, direction: You can't go that way.

A not understood term: I don't understand the word "invalid input" -- where the word just entered is repeated within the quotation marks.

Additional Program Processing

Implement the original rooms, locations, and artifacts as shown in this assignment. Additional rooms and artifacts must meet the following requirements:

Rooms. Add seven more university-themed rooms of your own choosing representing the Cal Poly Pomona campus (e.g., computer labs, farm store, brew works, recital hall).

Artifacts. Add three ordinary artifacts and three special artifacts appropriate for a university campus (e.g., lamp, radio, book, computer). Special artifacts should include relevant descriptions for their states.

Note: Be sure to identify all room and artifact locations on your map.

Constraints

1) Modify the initial design by adding at least seven more rooms of your own choosing. The following constraints apply to this section.

a) Rooms must have at least one and no more than three exits.

b) Additional exits can be used to supplement the original design, but none of the original exits can be modified in any way.

c) Leave one room empty.

d) Add at least one diagonal exit.

e) Display full names for exits, not abbreviations, so north, northeast, south, and so on.

f) When quit is requested, only a prompt of Y will cause the game to exit.

Test Data and Calculations

Using the sample data provided, build a table of test data. The format for your test table should be as follows: see image.

Classes and Responsibilities

This project requires the construction of multiple classes and methods for successful implementation. The following structures are a minimum. These structures can be supplemented as necessary. You are to create any remaining classes, variables, and methods as appropriate for your finished program.

Class name: GCPUApp
Responsibility: Contains application’s main method and handles user dialog

Class name: Map
Instance Variables: Room [ ][ ] rooms

Method name: Map ( )
Responsibility: Constructor for initial placement of rooms and artifacts

Class name: Room
Instance Variables: String name, String description, String exits, Artifact artifact

Method name: Room (String name, String description, String exits)
Responsibility: Constructor for initial configuration for a room

Method name: String getExits ( )
Responsibility: Returns the room exits in full text form (e.g., “north and south” (not “n and s”)

Method name: String look ( )
Responsibility: Returns names of artifacts, if any, found in room

Method name: boolean isValidExit (String requestedExit)
Responsibility: Returns true if requested exit exists for this room

Class name: Artifact
Instance Variables: String name, String description

Method name: Artifact (String name, String description)
Responsibility: Constructor for initial configuration for a room

Method name: String examine ( )
Responsibility: Returns name and description

Method name: String touch ( )
Responsibility: Returns a generic message (e.g., “Touching the desk doesn’t appear to do anything.”).

Class name: SpecialArtifact (extends Artifact)
Instance Variables: boolean state, String onDescription, String offDescription, String touchOnDescription,
String touchOffDescription

Method name: String examine ( )
Responsibility: Returns name and corresponding description for current state

Method name: String touch ( )
Responsibility: Changes state (e.g. open/close, on/off) and returns corresponding touch description

Initial Room Descriptions:

see image.

Initial Artifact Descriptions:

see image.

Sample Output for a Partial Session:

Welcome to the Great Cal Poly Underground! (Version 2.0)
You have entered a box canyon.
This looks like the Voorhis Ecological Reserve.
A cavernous opening in the canyon wall lies just ahead of you.
There is an opening to the north.

> look
box canyon
This looks like the Voorhis Ecological Reserve.
There is an opening to the north.
There is a paper here.

> examine
The paper appears blank.

> touch
The paper begins to glow and you see mysterious writing appear.

> examine
The paper reads: Welcome to the Great Cal Poly Underground!

> touch
The writing fades.

> examine
The paper appears blank.

> n
You have entered the Kellogg Mansion.
This is the former home of William Kellogg.
There is an opening to the east.

> look
Kellogg Mansion
This is the former home of William Kellogg.
There is an opening to the east.
There is a picture here.

> touch
Touching the picture doesn’t appear to do anything.

> hello
I don’t understand the word “hello”.

> e
Los Olivos
You have entered Los Olivos.
The smell of hamburgers and pizza wafts through the air.
There are openings to the north and west.

> quit
Do you wish to leave the Underground (Y/N)? > Y
Thank you for visiting the Great Cal Poly Underground.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.