Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions