CS120
Assignment #6
Due at midnight on Monday Oct. 13th
Beginning withyour Pet program from lab 6 (i.e. the version of the
pet program with your modifications from lab) make the following
additional modifications:
- Have the player lose if a pet is overfed, i.e. if hungry gets to 0 or less.
- Add another quality to pets that can change and add menu options
that allow the player to change that quality. For example, you could add
sleepy as a quality and playing with or feeding the pet causes it to increase, but
the pet can take a nap causing it to decrease. Other options are health: going
to the vet increases it, but some activities may decrease it; or money:
participating in pet shows causes it to increase (winning prizes), but feeding
the pet decreases it (buying pet food). (Chapter 5, Excercise 9 in the text.)
- Whatever new quality you pick for pets change the program
so that the player will lose when appropriate. For example, if you add
health as a pet quality and the pet get's too unhealthy the player should lose,
or if they player runs out of money they shouldn't be able to feed their pet
(until they can earn more).
- Add a new random event method (function member) to the pet class.
At the end of every main loop have there be a chance of calling the function.
(Use a random number generator and if the random number is less than some
limit call the random event mthod.)
The random event method should use a random number and a swtich statement
to have one of at least five random events occur that effect the pet. Random
events can be good ("Found a new pet toy." - happiness increases) or bad
("Spoiled pet food." - hungry increases).
Make sure that all of your additional operations are clearly represented in
the user menu of options.
If you can't get all of the modifications done (and for some of the
assignments you probably won't)
be sure to list which ones you've completed in the comments at the
beginning of the program. On the other hand if you did extra work on a
lab or assignment (and sometime you will want to) also describe the extra work in
the comment at the
beginning of the program.
Include a block of comments at the beginning of the program
(or add to the existing block) that lists your name, section number, date,
and the assignment number. Also include comments on any parts of the
assignment you didn't finish or on any extra work you did.
Include this comment block at the beginning
of every assignment and lab.
Turn in: Name your code file Assignment6SecX.cpp (where X is your section number) and turn in the code for your program (the .cpp file, not a.out) using the
cscheckin command.