Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

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?

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M9715963
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Java

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As