CS120
Programming Assignment #5
Due on or before September 27 at 11:59 PM.
For this assignment you will be expanding your adventure game by adding three 'helper' functions
that interact with rooms. Two of the functions are defined below, the third is up to you.
Requirements:
- Menu Function: Currently in each room the player has to select from a menu of options.
Generally, the user does not get good feedback if they enter an illegal value. Create a
function called menu() that can be called from any room, to force the user to select a menu option from a
specified range. In particular:
- The function should be used in the room code like this: choice = menu(1,5); (where the numbers may vary).
- The two integer arguments represent the lower and upper bounds of the menu options.
- The menu() function should tell the user the range of options (e.g. 1 to 5).
- The menu() function should keep looping, printing error messages as appropriate, until the
player enters a valid choice.
- The menu() function should return the player's valid choice.
- The second function should be a Nim game inside your adventure game.
In some room in your game, you should make it so that the player enters the room
and has to play Nim until they win a game in order to leave the room.
To do this you can copy all the code in main() from the Nim assignment, rename main to nim(), and call the new nim() function from the room that you want the player to play Num in.
Note that you will probably have to modify the new nim() function a little bit so that it will loop until the player wins.
- A third function of your choice.
The function should be called from within one or more rooms. Some possibilities include: a function that tells the player's favorite and least favorite numbers, a function that does some type of 'combat'
between the player and enemies, a function that makes the player solve a math problem correctly, etc.
- Remember to put a comment at the beginning of your code with
your name, section number, assignment number, etc.
Turn in: Use the script command to demonstrate how your program runs.
Place the output from the script command into a file named Assignment5output.txt.
In the sample output, make sure you demonstrate the three helper functions that you built for this assignment.
Turn in a copy of your program code and the Assignment5output.txt file to Canvas.