The primary goal of this programming assignment is to give students experience defining and using functions. You will start with a partial implementation of a game modeled after the 1970's computer game called "Adventure". This game was written before computer graphics was invented, so the game was all "text based" (and still a huge hit).
Your partial program hw3.cpp consists of five functions and an empty main program. Three of the functions describe what is found in different rooms of the cave. The other two functions are used to add to the total treasure and get directions from the user playing the game. To finish the game you must complete the following four tasks:
Design a maze of rooms: On a piece of paper, draw a maze of 8 rooms, with room1 as the start of the maze, and room99 as the exit of the maze. Draw a collection of N,S,E,W lines connecting the rooms to each other. Try to make it a little tricky to make it from room1 to room99. When you reach room99, the program will print a message and exit.
Create new room functions: Using the three room functions as examples, you will have to write 5 new room functions with short descriptions of what is found in each room. Your descriptions don't need to be long, but make sure they are "politically correct" so you can demo your game to your friends and family.
Add room navigation: The current room functions print out room descriptions and add to the total treasure, but they are not connected to each other in any way. You need to add some code somewhere in the program to ask the user for directions. Using this information and your map from above, you need to call the corresponding room functions. For example, if room42 is N of room17, then you should call the room42 function when the user types an N when they are in room17. Similarly, when the user types S in room42, they should return back to room17.
Play the game: Add some code to the main function to initialize variables and start the game in room1 of the maze. Then type in a sequence of N,S,E,W commands to move through the maze and collect gold on the way to the room99 exit. Save a copy of your program output in a text file to be included in your final report. For example, here is a copy of our game output.
Students are allowed to use any combination of C++ features we have discussed in class or lab. You are not required or allowed to look ahead to more advanced C++ features like arrays, files or classes to perform this task.
For this assignment, you have two big design decisions. First, you must create your map of 8 rooms in the maze. Connecting your rooms with N,S,E,W is the fun part. One tricky point is deciding what to do if a user types in E when they are in a room that does not have another room to the E side. The normal solution is to stay in the room and ask for directions again. You can think of this as a line that loops back to the same room.
Second, you need to figure out how to read user directions and use this information to go from room to room. This can be done in two ways. You can add function calls to the bottom of each of the room functions, or you can add a game control loop in the main function. This is probably the most difficult task in the project, so spend a little time thinking about it.
Since you are starting with our sample program, you already have something that compiles and runs. Since you must add several features to this program, it is important to make these changes incrementally one feature at a time, writing comments, adding code, compiling, and debugging. This way, you always have a program that "does something" even if it is not complete.
Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Try your program with several input values, and save your testing output in text files for inclusion in your project report.
When you have completed your C++ program, write a short report (less than one page long) describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this report in a separate text file to be submitted electronically.
In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted. When you have completed the tasks above go to the class web site to "upload" your documentation (a single pdf or txt file), and your C++ program (a single cpp or txt file). Do NOT upload an executable version of your program.
The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit: