CSCE 2004 - Homework 4
Due Date - Oct 16, 2014 at 11:59 PM

10% off if handed in by Oct 17, 2014 at 11:59 PM
20% off if handed in by Oct 20, 2014 at 11:59 PM
30% off if handed in by Oct 21, 2014 at 11:59 PM
No credit if handed in after Oct 21, 2014

1. Problem Statement:

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

Your partial program hw4.cpp consists of seven functions and an empty main program. Four of the functions describe what is found in different rooms of the cave. The other functions are used to update the player's treasure and health, 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 room42 as the exit of the maze. Draw a collection of N,S,E,W lines connecting the rooms to each other. It is OK to have multiple lines connecting two rooms. When you reach room42 the program will end.

Create new room functions: Using the four room functions as examples, you will have to write four 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 but they are not connected to each other in any way. You need to add code to call "GetDirection" somewhere in the program to prompt the user for N,S,E,W directions. Using this information and your map from above, you need to change what room the user is in, and call the corresponding room function. This can be done by adding recursive calls in each room function, or by implementing the room transition in the main program.

Update the player's gold and health: Add code to the room functions or the main program to call the "RandomTreasure" and "FightBattle" functions and update the user's gold and health accordingly. You will notice that both of these functions use the built-in random number generator so different values are returned every time they are called.

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 room42 exit. Use "script" and "exit" to save everything to the file "typescript", and include some sample output in your project report.

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.

2. Design:

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 implement the player's movement from from room to room. This can be done in two ways. You can add recursive 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.

3. Implementation:

You will be starting with the sample hw4.cpp program to implement this project. This program compiles and runs but it does not do anything interesting. It is very important to modify your code incrementally writing comments, adding code, compiling, debugging, a little bit at a time. This way, you always have a program that "does something" even if it is not complete.

4. Testing:

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.

5. Documentation:

When you have completed your C++ program, write a short report using the project report template 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 to be submitted electronically.

6. Project Submission:

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.

Rename your program and documentation files 123456789.hw4.cpp and 123456789.hw4.docx using your UAID number in place of 123456789, and go the Blackboard site for this class and submit these two files.

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:

You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended.

7. Academic Honesty Statement:

  • Students are expected to submit their own work on all programming projects, unless group projects have been explicitly assigned.
  • Students are NOT allowed to distribute code to each other, or copy code from another individual or website.
  • Students ARE allowed to use any materials on the class website, or in the textbook, or ask the instructor and/or GTAs for assistance.
  • This course will be using highly effective program comparison software to calculate the similarity of all programs to each other, and to homework assignments from previous semesters. Please do not be tempted to plagiarize from another student.

    Violations of the policies above will be reported to the Provost's office and may result in a ZERO on the programming project, an F in the class, or suspension from the university, depending on the severity of the violation and any history of prior violations.