In this exercise you will write a program that allows the user to care for a virtual pet.
To properly maintain the pet the user will need to feed it, interpret its mood, and walk it.
Note: The pet will be embedded with communication skills so that it can communicate its state of mind, which can
range from happy to mad.
Task 1: Plan the Pet class
The core of this application is the pet itself.
Begin by planning the Pet class.
Identify the private members that describe the pet.
The pet will need to store independent hunger and boredom levels.
As time passes, the pet becomes hungry and its boredom level rises.
Expect the pet's mood to be dependent on its current hunger and boredom levels.
The owner of the pet needs to be able to communicate with the pet.
Task 2: Identify the public methods for this class
The user needs to be able to feed and play
with the pet to reduce its hunger and boredom levels.
To do this, the pet will need to be able to communicate its mood to the user.
You will also need to simulate the passage of time. This method will be
private because it will only be called by other member methods (feed, walk, or talk).
Task 3: Identify how the user will operate his/her pet
Describe the basic operating procedures for using the pet.
Here is sample pseudocode for the application program:
Upon execution, a pet is created.
Do-while the user doesn't want to quit
Display a menu of choices to the user: Talk, Feed, Walk, or Bye to Exit.
if the user wants to talk, the pet will describe its mood.
if the user wants to feed his pet, make the pet eat a fixed amount.
if the user wants to walk his pet, make the pet walk walk a mile.
Task 4: Code the files for the Virtual Pet.
Create the following files:
Code the Pet class.
Create an application file containing a program with a main() method.
This main function will be pretty simple.
Instantiate a Pet and use a game loop that asks the user
whether he/she wants to talk to, feed, or play
with the pet, or quit the program.
Task 5: Modify Pet.
Assume all pets will randomly misbehave. Implement misbehavior into your pet class. Use the following guidelines. :
Assume all pets are individual in terms of bad behavior. Each pet will misbehave a fixed percent of the time.
A bad pet must be disciplined.
Each time it misbehaves, it becomes more independent and unwilling to communicate with its owner.
Once a pet has reached a high level of independence, it will refuse to talk.