Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

and here is the pet code you need #include #include using namespace std; // declaration of the pet class class pet{ private: int hunger; //

image text in transcribed

and here is the pet code you need

#include #include using namespace std; // declaration of the pet class class pet{ private: int hunger; // private data member string name; // private data member int happy; // private data member public: pet(); // constructor void play(); // public member function void feed(); // public member function void print(); // public member function int check_health(); // public member function }; int main() { pet pet1; int choice; int health_check; do{ pet1.print(); cout > choice; switch(choice){ case 1: pet1.play(); break; case 2: pet1.feed(); break; } health_check = pet1.check_health(); }while(choice != 0 && health_check != 1); cin.ignore(); cout > name; } /* Member function play(), allows playing with a pet. */ void pet::play(){ int choice = 0; cout > choice; switch(choice){ case(1): happy += 10; hunger += 5; break; case(2): happy += 5; hunger += 1; break; default: cout = 100){ cout   For this assignment, you will be modifying the Pet Program we worked with earlier. You should work from the version you created in assignment 7. If you didn't complete Assignment 7 you may work from the original Pet program, but make that clear in the comments at the beginning of your program. For either approach it is recommended that you begin with a copy of the code, so you have the old version to go back to The general idea for this program is that the player has four pets, stored as an array, rather than just one pet that they can interact with. This will require making the following additions to the progran: Create an array of four pet objects Change the ending condition of the main loop so that the loop only ends if all four pets die. This will probably require creating an extra variable to keep track of the number of pets that are still alive (or that have died) Each loop of the program should begin by giving the player a choice of pets (by name) to interact with. For example Which pet do you want to interact with? 1) Bob 2) Sally 3) Rover 4) Tiddles The player then enters a number (1-4) and the program moves onto the regular interaction menu (play, feed, etc.). Note that pets that have died should not be included in the list .When the player interacts with a pet that interaction should only effect that pet. For example, if the player chooses to feed Bob then only Bob should get less hungry However, the random events may occur to other pets. So, even though the player fed Bob Sally may have had a random event occur to her

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

13.4 Specification Bias

Answered: 1 week ago

Question

2. What are your challenges in the creative process?

Answered: 1 week ago