Question: Create a class PetSim using the following UML class diagram: PetSim -hungerLevel: int -boredomLevel: int -name: string +Talk(): void +FeedPet(): void +Play(): void +PetMood(): void

Create a class PetSim using the following UML class diagram:

PetSim

-hungerLevel: int

-boredomLevel: int

-name: string

+Talk(): void

+FeedPet(): void

+Play(): void

+PetMood(): void

+PassTime(in time: int =1): void

+DisplayPetBehavior(): void

+Menu(): void

Code C++ with header.h file, fuction.ccp file and main.cpp file with the following condition:

Class contain and overloaded constructor, set and get functions.

Constructor takes three arguments: hunger, boredom and name. Also prints the initial statistic of the pet.

PetMood() function is directly based on its hunger and boredom levels. This function returns the sum of pet's hunger and boredom level. Pet's get worse as the number increase.

Talk() function is allows the pet to be able to tell the player how it's feeling. Pet can be happy, Ok, frustrated or mad. The return value for happy is less than 7, Ok is 7 or higher, frustrated is between 16 and 21, and mad if greater than 21.

FeedPet() function allows the player to be able to feed pet to reduce its hunger. Max amount of food that can be fed to pet is value of 4. Pet's hunger level is kept in check and is not allowed to go below zero.

Play() function allows the player to be able to reduce the pets boredom. Max amount of fun a pet can have is 4. The boredom level is kept in check and is not allowed to go below zero.

PassTime() is a private member function that increase pet's hunger and boredom level by adding the specified amount of time to the member variable hungerLevel and boredomlLevel.

DisplayPetBehavior() displays appropriate pet behavior based on the hunger level and boredom level.

Menu() function is basically be a game loop that asks player whether he want to listen to, feed, or play with the pet or quit the game.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!