DUE: Tuesday, May 11 before 11:00pm
Collaboration is strictly FORBIDDEN. Programs must represent YOUR OWN original work. Sharing code or team-coding are not allowed for this assignment. Copying code from ANY source (any book, current or past students, past solutions, the web, etc.) is not allowed. Cooperation to the extent of helping to debug, or discussing the general approach to solving the problem is encouraged, but should never involve communicating code or even pseudo-code or explicit algorithms. Your code must be unique -- if it is not, we will find out, and will treat it as a case of flagrant academic dishonesty.
You must turn in a C++ source file (and only a C++ source file). The name for your source file should be as5.cpp.
Turn in online to the appropriate folder for your lab section (e.g., as5_sec20 for students enrolled in lab section 20). If you turn your assignment in to the wrong folder, your assignment may not be graded. If it is graded, you will lose 2 pts (out of 10).
Remember to include the header as it is in the template provided on the class website.
Write a simple text adventure game. In this game, the player will start out in a room that has 4 walls. Each wall has one door. Three of the doors open up to a closet, and the 4th door is an exit. Inside one of the closets will be a monster. Inside another closet will be a genie. Inside the last closet will be a picture. The player will begin the game holding two types of items, bananas and oranges. They should start out with 5 bananas and 3 oranges.
The game should ask the player to open a door. If the player opens the closet door with the monster inside, the monster will steal all of the bananas and oranges the user is holding. If the player opens the closet door with the genie inside, the genie will give the user 2 bananas and 1 orange. If the player opens the door with the picture inside, the game should just draw the picture to the screen. Finally, if the player chooses the door to the exit, the game should end. When the game ends, give the player his score. The score is the total number of bananas and oranges he is holding when he exits the room.
You must write a function for each closet. When the player chooses a door in a certain direction (N/E/S/W), the program should call the function for the closet in that direction or end the program if they chose the door to the exit. You will need variables to store the number of bananas and oranges the player has on them.
Here is what each function should do:
Please enter your name: Kris
Name your scariest monster: Pinhead
Kris, you are in a room with 4 doors.
You are carrying 5 bananas and 3 oranges.
Pick a door to open by typing the direction it is in (N/E/S/W): N
WATCH OUT!!
Pinhead attacks you and steals all of your bananas and oranges.
Kris, you are in a room with 4 doors.
You are carrying 0 bananas and 0 oranges.
Pick a door to open by typing the direction it is in (N/E/S/W): S
You found a picture!
*******
* *
* 8 8 *
* & *
* _ _ *
* --- *
* *
*******
Kris, you are in a room with 4 doors.
You are carrying 0 bananas and 0 oranges.
Pick a door to open by typing the direction it is in (N/E/S/W): E
!!POOF!!
A genie pops out and grants you 2 bananas and 1 orange.
Kris, you are in a room with 4 doors.
You are carrying 2 bananas and 1 oranges.
Pick a door to open by typing the direction it is in (N/E/S/W): W
You found the exit!
Your score is 3 (2 bananas and 1 oranges).
Bye bye!!!
For 2 pts BONUS, have the closets and exit move around randomly from game to game. So, the first game the East door may open the closet that has the monster. The next time the game is played, the East door may be the exit.
If your program does not compile, it will not be graded. Compile your code often. Only write a small portion of code before checking that it still compiles. This way when you get a syntax error, you can be fairly certain the error is in the part you just wrote.
1 pt: Input error checking (Only N/E/S/W can be chosen for directions)
2 pts: Correct output
- (.5 pts) Outputs player's name when asking which door to open
- (.5 pts) Outputs player's scariest monster from within monster
function
- (.5 pts) Outputs # of items player has after opening each door
- (.5 pts) Outputs score before exiting program
5 pts: Functions (including proper use of reference vs. value parameters)
- (2 pts) DOES NOT USE GLOBAL VARIABLES
- (1 pt) Monster function
- (1 pt) Genie function
- (1 pt) Picture function
2 pts: Style
- (.5 pts) Good variable/function names
- (.5 pts) Proper indentation/spacing
- (.5 pts) Good comments (including header and function comments)
- (.5 pts) No line wraps