Homework 8

Make a class called Room and a main() function that allow a user to “walk through a maze.” Here is an example interaction:

You are in the Garden. The trees and shrubs appear to be resilient to
decades of neglect but the flowerbeds all withered away long ago.

There is an exit to North (Kitchen) and East (Library).

Which exit? (or 'quit'): north

You move to the North...

You are in the Kitchen. Knives, pots, pans, and other kitchenware
dangle over the island like some kind of metallic chandelier.

There is an exit to North (Hallway), East (Library), and South
(Garden).

Which exit? (or 'quit'): west

There is nothing over there.

Which exit? (or 'quit'): east

You move to the East...

The Room class should have at least these methods:

You should support room links such as ‘North’, ‘South’, ‘out the window’. Use a map (key is the direction, a string; value is the Room pointer).

You can establish the maze in the code (in the main() function probably); the maze need not be designed by the user interactively (that would be slightly harder).

There is no particular need for polymorphism in this program’s code, but you should use private and public data/methods in your class (make a meaningful separation). Also, split your code into three files: room.h, room.cpp, and main.cpp.

Once you have set up the maze, set up the Thing class. For the homework add a Lock to one of the rooms and a key is hidden in another room. The goal of the game is for the User to find the key and open the lock.

This may be interesting if you have some free time: http://www.kongregate.com/games/2DArray/you-find-yourself-in-a-room

You can also play the original (updated to be played in a browser) Colossal Cave Adventure

CSE 2122 material is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Source code for this website available at GitHub.