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.:- M9130693
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Java

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

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

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

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

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

  • 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