CSCI 110 - Programming Assignment 3 - Due: Friday, March 7, 3pm
Program Description
This program will give you practice using
conditionals, a single while loop, and functions. As always, proper documentation,
appropriate use of constants and identifiers and good programming style is expected.
Imagine that you suddenly find yourself in a dark room.
The room is sealed and has
only 120 minutes of air. There is an exit but there are also hazards: a waterhole
which, if you fall in, causes you to use up an extra 10 minutes of air, walls
which you may not walk through and a bottomless pit from
which you cannot escape. There is also a an air tank hidden, which holds an
additional 20 minutes of air. You will search for the exit using the arrow keys,
each key stroke uses a minute of time. I have provided a program which moves
a player and generates all special positions: p3.cpp.
To make this game somewhat interesting to the player, the initial position of
the player and all special locations will be randomly
generated using rand( ) and should not be printed until the end of the
game. For testing purposes, however, I strongly suggest
that you assign values to these locations rather than calling
the function I have given you to generate random locations.
Input
The only input to this program is the player entering
moves via the arrow keys or the letter 'q' to signify that the player wishes
to quit. The code necessary to read input has been provided in the partial program
I have provided for you.
Manipulations
You must make appropriate use of functions when
testing for the special locations. In addition:
- whenever the player strikes a wall, your program
should signify this writing an appropriate message at the top of the screen
- if the player lands in the bottomless pit, an appropriate message
should be displayed and the game terminates
- if the player finds the additional air supply, an appropriate
message should be displayed and air supply updated
- if the player lands in the water, an appropriate message should be
displayed and air supply updated
- if the player is within two moves
of the way out, change the color of the cursor, signifying
that he/she are getting closer to the exit
- if the player finds the exit, an appropriate message should be displayed
and the game terminates
- whenever the game ends, for whatever reason, all
special locations should be displayed, the amount of air used (or remaining)
should be displayed, and a message about how the game ended should be
displayed.
After
you have thoroughly tested your program with assigned values for
initial and special positions, be sure to call my function GenerateAll
to randomly specify the locations.
Submitting your Program
After thoroughly testing your program, place a copy of your source code
on the G: drive no later than Friday, March 7, 3pm. You must also
give me a copy of the source code bearing your honor code signature by
that time.