### CSC 222: Computer Programming II Spring 2004 HW3: Structuring Data & Classes

One of the first computer games in the 1970's was an adventure game called "Hunt the Wumpus". In this game, you are forced to wander around a maze of caves, hunting the dreaded wumpus (or possible more than one wumpi). When you enter a cave that is adjacent to a wumpus, you will smell its stench. Warned by your nose, you can then throw a hand grenade into an adjacent cave to try to kill the wumpus. Unfortunately, the sound of the explosion will alert any nearby wumpi and set them in motion. The object of the game is to kill all of the wumpi before you run out of grenades (and without getting killed). In addition to wumpi, there is a bottomless pit and giant bats to avoid. Below is a sample execution of the game.

 HUNT THE WUMPUS: Your mission is to explore the maze of caves and destroy all of the wumpi (without getting yourself killed). To move to an adjacent cave, enter 'M' and the tunnel number. To toss a grenade into a cave, enter 'T' and the tunnel number. You are currently in The Fountainhead (1) unknown (2) unknown (3) unknown What do you want to do? m 2 You are currently in The Silver Mirror (1) The Fountainhead (2) unknown (3) unknown What do you want to do? m 3 You are currently in Shelob's Lair (1) The Silver Mirror (2) unknown (3) unknown You smell an awful stench coming from somewhere nearby. What do you want to do? t 2 Missed, dagnabit! DANGER: Any nearby wumpi are on the move. A wumpus is coming toward you with big, gnarly teeth... CHOMP CHOMP CHOMP GAME OVER

You have been given the following classes to represent the maze structure and implement the text-based game: wumpus.cpp, Cave.h, Cave.cpp, CaveMaze.h, CaveMaze.cpp, Die.h, Die.cpp, and caves.dat. In order to complete the program, you must:

• Complete the implementations of the Cave member functions in Cave.cpp.
• Modify wumpus.cpp so that user input is handled in a more robust way. The user must enter 'm' or 'M' for Move, 't' or 'T' for Toss, and 1, 2, or 3 for the target cave number. Any input other than these should produce an error message and should then be ignored.