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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started