I've gotten stuck on this practice problem. I need help figuring this out. I HAVE to keep it in 3 seperate files, and I'm not allowed to change the main.cpp file at all. Also all data members need to be private You need to make a Pet class that holds the following information as private data members: the name of the pet (e.g. "Spot", "Fluffy", or any word a user enters) the type of pet (e.g. dog, cat, snake, hamster, or any word a user enters) level of hungriness of the pet (2 means hungry, 1 means content, 0 means full) Your class also needs to have the following functions: a default constructor that sets the pet to be a dog named Buddy, with level of hungriness being “content” a parameterized constructor to allow having any type of pet the order of the parameters is: name of the pet, type of pet, hungriness level a PrintInfo function that prints the info for the pet according to the sample output below a TimePasses function that increases the hungry level of the pet by one (unless its hungry level is already 2, meaning hungry). a FeedPet function that changes the hungry level of the pet to 0 (Full) You must write your class in separate .h and .cpp files. We have set zybooks up so that the files are already provided for you, and you can edit them directly in zybooks, or copy-paste from an IDE that you do your work in. You can switch between files by clicking the drop-down menu above the editing space in zybooks. Sample Output For a default pet (dog, named “Buddy”, content): A dog named Buddy who is hungry level 1. For a pet cat named Fluffy, who is content:: A cat named Fluffy who is hungry level 1. For a hamster named Sparky who is full: A hamster named Sparky who is hungry level 0. Main.cpp #include "Pet.h" int main() {Pet firstPet;Pet secondPet("Fluffy", "cat", CONTENT_HUNGRY); firstPet.PrintInfo(); secondPet.PrintInfo();secondPet.TimePasses();secondPet.PrintInfo();secondPet.FeedPet();secondPet.PrintInfo(); Pet thirdPet("Sparky", "hamster", NOT_HUNGRY);thirdPet.PrintInfo();return 0;} Pet.h #ifndef PET_H_INCLUDED#define PET_H_INCLUDED#include "Pet.cpp"#include "main.cpp"#include <string>#include <iostream>using namespace std; class Pet{public:Pet();void PrintInfo();void TimePasses();void FeedPet();Pet("Buddy" , "dog" , 1);private:string petName;string petType;int petHungerLevel;const int NOT_HUNGRY = 0;const int VERY_HUNGRY = 2;const int CONTENT_HUNGRY = 1; } #endif Pet.cpp #include <iostream>#include <string>#include "Pet.h"#include "main.cpp"using namespace std; void Pet::petName(){}void Pet::petType(){}void Pet::petHungerLevel(){}
I've gotten stuck on this practice problem. I need help figuring this out. I HAVE to keep it in 3 seperate files, and I'm not allowed to change the main.cpp file at all. Also all data members need to be private
You need to make a Pet class that holds the following information as private data members:
- the name of the pet (e.g. "Spot", "Fluffy", or any word a user enters)
- the type of pet (e.g. dog, cat, snake, hamster, or any word a user enters)
- level of hungriness of the pet (2 means hungry, 1 means content, 0 means full)
Your class also needs to have the following functions:
- a default constructor that sets the pet to be a dog named Buddy, with level of hungriness being “content”
- a parameterized constructor to allow having any type of pet
- the order of the parameters is: name of the pet, type of pet, hungriness level
- a PrintInfo function that prints the info for the pet according to the sample output below
- a TimePasses function that increases the hungry level of the pet by one (unless its hungry level is already 2, meaning hungry).
- a FeedPet function that changes the hungry level of the pet to 0 (Full)
You must write your class in separate .h and .cpp files. We have set zybooks up so that the files are already provided for you, and you can edit them directly in zybooks, or copy-paste from an IDE that you do your work in. You can switch between files by clicking the drop-down menu above the editing space in zybooks.
Sample Output
For a default pet (dog, named “Buddy”, content):
A dog named Buddy who is hungry level 1.
For a pet cat named Fluffy, who is content::
A cat named Fluffy who is hungry level 1.
For a hamster named Sparky who is full:
A hamster named Sparky who is hungry level 0.
Main.cpp
#include "Pet.h"
int main() {
Pet firstPet;
Pet secondPet("Fluffy", "cat", CONTENT_HUNGRY);
firstPet.PrintInfo();
secondPet.PrintInfo();
secondPet.TimePasses();
secondPet.PrintInfo();
secondPet.FeedPet();
secondPet.PrintInfo();
Pet thirdPet("Sparky", "hamster", NOT_HUNGRY);
thirdPet.PrintInfo();
return 0;
}
Pet.h
#ifndef PET_H_INCLUDED
#define PET_H_INCLUDED
#include "Pet.cpp"
#include "main.cpp"
#include <string>
#include <iostream>
using namespace std;
class Pet{
public:
Pet();
void PrintInfo();
void TimePasses();
void FeedPet();
Pet("Buddy" , "dog" , 1);
private:
string petName;
string petType;
int petHungerLevel;
const int NOT_HUNGRY = 0;
const int VERY_HUNGRY = 2;
const int CONTENT_HUNGRY = 1;
}
#endif
Pet.cpp
#include <iostream>
#include <string>
#include "Pet.h"
#include "main.cpp"
using namespace std;
void Pet::petName(){
}
void Pet::petType(){
}
void Pet::petHungerLevel(){
}
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)