Modeling the caves

Assignment Help JAVA Programming
Reference no: EM1341858

Assignment 2 Description

You are a mighty warrior, and armed with your trusty bow and 3 arrows, you enter The Caves in search of the mighty Wumpus. If you shoot the Wumpus, you are victorious and the masses will praise you, but if you stumble upon the Wumpus unaware, it will eat you! Also, beware of the webs of the giant poisonous spiders and the bottomless pits!

Your senses of smell and hearing will aid you on your quest, for the Wumpus does not bathe and can be smelled one room away. Also, the clicking mandibles of the poisonous spiders can be heard one room away, and the foul odor of a bottomless pit can be smelled one room away.

For this project, you will implement a program that lets the user play Hunt the Wumpus!

Modeling the Caves

The layout of the cave rooms is specified in a text file that looks like this (you may use this text file, but it is not required):

10

1 2 6 10

A wooden sign reads "Beware of the Wumpus!"

2 1 3 7

There is a black pool of water in the corner.

3 2 4 8

You see a Tyrannosaurus Rex fossil embedded in the wall.

4 3 5 9

There is an empty Diet Rite can here.

5 4 6 10

You almost step on a broken cellular phone.

6 1 5 7

A couple of evil rats stare at you from under a pile of rocks.

7 2 6 8

You find a Spanish doubloon on the floor.

8 3 7 9

The ceiling is very low and you have to stoop.

9 4 8 10

You step on a slippery spot, slip, and fall on your keester.

10 1 5 9

You get a strong sense of deja vu.

The first line of the text file gives the number of rooms in the caves (your program should handle any number of rooms). Each room is described on two lines: the first gives the room number, the room numbers of the three adjacent rooms (there are always 3); the second gives a string that describes the room.

Put this cave layout (or one in a similar format) into a text file. Declare a class to represent a single cave room (Room), and then declare an array of rooms to hold the entire cave in your main program. One of the first things your program should do is open and read the layout file and put the information into your array of rooms.

 

Your program should then pick random numbers to figure out where to place the Wumpus, the two spider rooms (in two different rooms), and the bottomless pit. Make sure nothing ends up in room #1, as that is where the player starts, and don't put spiders, the Wumpus, or a pit in the same room together.

Playing the game

Here is a sample game. Comments in italics are not visible to the player, but are there to help explain what is happening. The user's input appears in boldface.

Welcome to **Hunt The Wumpus!**

You are in room 1.

You have 3 arrows left.

A wooden sign reads "Beware of the Wumpus!"

There are tunnels to rooms 2, 6, and 10.

You hear a faint clicking noise. (There are spiders in room 6)

(M)ove or (S)hoot?

M

Which room?

5

Dimwit! You can't get to there from here.

There are tunnels to rooms 2, 6, and 10.

(M)ove or (S)hoot?

M

Which room?

2

You are in room 2.

You have 3 arrows left.

There is a black pool of water in the corner.

There are tunnels to rooms 1, 3, and 7.

You smell a dank odor. (There is a pit in room 3)

You smell some nasty Wumpus! (The Wumpus is in room 7)

(M)ove or (S)hoot?

S

Which room?

3 (The user picks the wrong room)

Your arrow goes down the tunnel and is lost. You missed.

You are in room 2.

You have 2 arrows left.

There is a black pool of water in the corner.

There are tunnels to rooms 1, 3, and 7.

You smell a dank odor.

You smell some nasty Wumpus!

(M)ove or (S)hoot?

S

Which room?

7

Your arrow goes down the tunnel and finds its mark!

You shot the Wumpus! ** You Win! **

Enjoy your fame!

 

After the caves are all set up, the game proceeds. Have an integer (perhaps called currentRoom) to keep track of which room the warrior/player is in currently. Your program will then repeat the following loop:

1. Display the information about the current room. Print the room number, its description, and the list of adjacent rooms. Also check if any of the adjacent rooms have spiders, a pit, or the Wumpus and print a smell/hear message as appropriate. (If adjacent to two pits, only print one smelly message.) You might also display the number of remaining arrows.

2. Ask the player if he/she wants to move or shoot.

3. If the player shoots, have her/him pick which of the adjacent rooms to shoot into. If that room contains the Wumpus, the player wins and the game is over. If not, reduce the number of arrows by one. If the player runs out of arrows, they lose.

4. If the player moves, ask for the room number and change room. If the new room contains spiders, a pit, or the Wumpus, the game is over.

Do not let the user move or shoot into a room that is not adjacent to the current room.

Additional Requirements

On the first line of the cave layout file, after the number of rooms, have your program accept the number of spider rooms and bottomless pits. Thus, if the first line was

 

25 5 3

your cave would have 25 rooms, with 5 of those having poisonous spiders, and 3 rooms with pits. These rooms are still chosen randomly.

? Add a supply room that contains arrows. If the player enters this room, their arrows are refilled back to 3. Note that the game does not end if the player runs out of arrows.

? Add a room (chosen at random) with giant bats. If the player enters that room, the bats pick him/her up and fly to a random room before dropping the player (unharmed). If the new random room has the Wumpus, a pit, or spiders, the game is over. The bats should move the player out of the room they are in.

 

Notes

1. Before you begin programming, sketch a high level design of what you want to implement using the UML notation. At the very least, you should have a use case diagram, class diagram (for the Room class) and a sequence diagram (for the game loop - 4 steps described above).

2. Remember to include comments at the top of your program and 1-2 lines for each function/method (for pre- and post-conditions). Make them javadoccompatible.

3. Think carefully about how you design your room class. If you do it well, this is not a hard program to write.

4. Write this program in pieces. First, type up the layout text file and write a program to simply read in the file and print the cave info on the screen so you know it is reading correctly. Then, you might try to set up the program so the player can move around, but there are no monsters or pits.

5. Start right away!

Hand In

Email me), in a single MS Word document with the following four clearly defined sections:

1. Listing (print-out) of your nicely formatted program source code (with comments and headers)

2. Print-out of the text file that contains your cave layout

3. Screen captures of at least three sample runs/scenario output

4. High level design using UML notation (minimum of use case diagram, class diagram for Room class, & sequence diagram for game loop as described in the four steps above)

5. Utilize the submission template provided in the course module.

Source code listing here.... 

/*******************************************************************************

 * Room Class

 *

 * Description here....

 *

 * Preconditions:

 * Postconditions:

 *

 * @authorStudent Name

 * @date

 * @version 1.0

 *

 ******************************************************************************/

publicclass Room {

 

declarations here...

 

       public Room(...) {

 

              logic here...

       }

 

       /*******************************************************************************

        * method

        *

        * Description here...

        *

        * Preconditions:

        * Postconditions:

        *

        * @authorStudent Name

        * @date

        * @version 1.0

        * @param ...

        * @return ...

        ******************************************************************************/

 

       publicvoidmethod() {

              logic

       }

 

       // sample method    

       publicbooleancheckWumpus() {

              returnwumpus;

       }

 

       // sample method    

       publicvoidsetSpiders() {

              spiders = true;

              enemy = true;

       }

 

       // sample method

       publicbooleancheckSpiders() {

              returnspiders;

       }

 

       // sample method    

       publicvoidsetPit() {

              pit = true;

              enemy = true;

       }

 

       // sample method

       publicbooleancheckPit() {

              returnpit;

       }

 

       // sample method    

       publicbooleancheckEnemy() {

              returnenemy;

       }

 

       // sample method    

       public String getDescription() {

              returndescription;

       }

 

       // sample method    

       publicintgetRoomNumber() {

              returnroomNumber;

       }

 

More methods here...

}

 

 

/*******************************************************************************

 * Game Class

 *

 * Description here....

 *

 * Preconditions:

 * Postconditions:

 *

 * @authorStudent Name

 * @date

 * @version 1.0

 *

 ******************************************************************************/

 

publicclass Game {

 

       publicstaticvoid main(String[] args) throwsIOException {

 

 

              FileReader r = newFileReader("cave.txt");

              Scanner s = new Scanner(r);             

 

Logic here...       

Place screen captures here of at least 3 runs (different scenarios) of your program (be sure they are readable).

Insert text file here...

Insert UML design diagrams here (use case, class, and sequence diagram)...

Reference no: EM1341858

Questions Cloud

Role of human resource unit in making strategic decision : What roles does the outside environment and competition have in formulating organizational strategy and explain the role of the human resource unit in making strategic decisions
Analyze the cultural and workforce differences : Analyze the cultural and workforce differences between the U.S. and this country. Summarize the differences and explain how each of these could create HRM issues for your U.S. management team such as job design, motivation, and other HRM issues.
Analyze methods for recognizing and retaining key employees : Find a process to replace key executive talent and Prepare a process to identify high-potential employees; develop a process to fast track these employees
Find the major hr challenges facing organizations : Make a presentation to a high school business class about human resources and the challenges facing this profession and Find the major HR challenges facing organizations and managers
Modeling the caves : Assignment 2 Description:  You are a mighty warrior, and armed with your trusty bow and 3 arrows, you enter The Caves in search of the mighty Wumpus. If you shoot the Wumpus, you are victorious and the masses will praise you, but if you stumble upon ..
Assess the challenges of the merger : Assess the challenges in creating cooperation between the two organizations and what elements of national culture need to be taken into account when assessing the challenges of the merger?
Create a recursive factorial program : Assignment 1: Create a recursive factorial program that prompts the user for an integer  N  and writes out a series of equations representing the calculation of  N !. For example, if the input is 4, the output could be:
Annotated bibliography - organization development and change : Prepare an annotated bibliography in APA format. Topic - Any topic regarding Organization Development and Change
Investigate a social issue paper : Investigate a Social Issue Paper,  Describe how your issue fits into the field of sociology.  Determine the sociological theories and terminology from the text that apply to your social issue.  (Note: Link back to the main points described in the out..

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  Design a single class that expresses the commonality

Design a single class that expresses the commonality of these concepts.

  Technical community blog

Write a blog article for a coding and technical community blog.

  Design and implement a small and simple email server

Design and implement a small and simple email server

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Write a program that reads a set of floating-point

Write a program that reads a set of floating-point data values from the input.

  File integrity checker - tripwire

Write a program that will perform some of the basic tasks accomplished by a file integrity checker such as Tripwire.

  Implementation of encryption and steganography in java

This is a project report showing the essential details and coding structures related with the implementation of encryption techniques and steganography in JAVA.

  Design a course registration system

Create an application which represents a simplified course registration system using ArrayLists and HashMaps.

  The objective is to implement a menu-based system

The objective is to implement a menu-based system for Bank Accounts in order to simulate a very simple banking system. Many structures have to be declared to manage bank accounts.

  Evaluate the rtas resource requirements

Design and implement a set of classes and interfaces and use them to evaluate the RTA's resource requirements.

  Enterprise java beans (ejb) in software development

Enterprise Java Beans (EJB) in software development, EJB technology, EJB application, Stateless Session Beans (SLSB), Stateful Session Beans (SFSB), Message Driven Bean (MDB), Entity Bean

  Solving programming problems

Write a computer program that will figure out the total of an order when given the amount of the order ($1000) and a sales tax rate of eight percent.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd