CS120
Programming Assignment #7

Due Friday Oct 13th at the beginning of lecture.

For this assignment you will be modifiying the pet program. Feel free to work from your version created for assignment 6 or from the program on the schedule.

For this assignment you need to add at least one new, numeric data member to the pet class. For example, a health value, an amount of money, a sleepiness value, etc.

Modify the existing pet interaction functions (feed() and play()) to also change this value. For example, if the new data is money feeding the pet costs money (for food), but playing with the pet gains money (your pet is doing tricks for tips?). Or if your new data is sleepy then both feeding and playing with your pet makes it sleepier.

Add a new interaction function (like feed() and play()) that allows users to interact with the pet in a new way that effects all of the current data. For example, if you added a sleepy data member, then there should be a nap() function that reduces sleepy, but increases hungry. Make sure to include this new interaction in the player menu so the player can select it.

Remember to add your new data member to the pet print() function so it tells the player how sleepy their pet is, or how much money they have left, etc.

Add a new random event function that is called after the player interacts with the pet - i.e. at the end of the main loop. This function should have a chance of one of several random events occuring (and a fairly large chance that no random event occurs). Random events should print a message to the player telling them what the event was and should effect the member data of the pet. You should make up your own random events. Examples would be "Your pet found a bone." happiness goes up and hunger goes down or "Your pet escaped from the backyard and was caught by animal control." happiness goes up, money (if you created it) goes down or "Your pet found a skunk." hapiness goes way down.

One way to implement the random event function is to generate a random number in some range (e.g. 0-9) and use a switch statement to determine the outcome. Many of the switch cases can default to no event, and a few of the cases can call functions with the special events.

Turn in: A copy of the program and sample output showing it runs. In the sample ouput make sure you show that you've tested all of the new functionality of the program.