Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <time.h>
- using namespace std;
- enum color { red = 0, grey, black, white, browns, striped };
- enum eyes { blue = 0, greys, green, yellow, brown, blind };
- enum act { look = 0, add_cat, add_rand_kitten, feed, stroke, play, treat, rename_cat, look_health, kill };
- enum food { meat = 0, fish, milk, grass, wet_food };
- class Cat
- {
- int age, weight, health, hunger, thirst;
- string name, color;
- bool gender;
- pair<string, string> eyes;
- public:
- Cat()
- {
- this->age = 0;
- this->health = 100;
- this->weight = 100;
- this->hunger = 50;
- this->thirst = 50;
- take_color();
- take_eyes();
- this->gender = true;
- this->name = "Cat";
- }
- Cat(int age, int weight, bool gender, string name)
- {
- this->age = age;
- this->health = 100;
- this->weight = weight;
- this->hunger = 50;
- this->thirst = 50;
- take_color();
- take_eyes();
- this->gender = gender;
- this->name = name;
- }
- void rename()
- {
- cout << "Old name: " << this->name << endl;
- cout << "Would you like change name your cat's?(1=yes, 0=no)" << endl;
- bool a;
- cin >> a;
- if (a)
- {
- cout << "Enter a new name: ";
- cin >> this->name;
- cout << "New name your cat is " << this->name << endl;
- }
- else {
- cout << "Name saved." << endl;
- }
- cout << endl;
- }
- void look()
- {
- cout << "Name your cat's is " << this->name << endl;
- cout << "Wool's color is " << this->color << endl;
- cout << "Left eye is " << this->eyes.first << endl;
- cout << "Right eye is " << this->eyes.second << endl;
- cout << "Age: " << this->age << endl;
- cout << "Weight: " << this->weight << "g" << endl;
- cout << endl;
- }
- void look_health()
- {
- cout << "Name your cat's is " << this->name << endl;
- cout << "Age: " << this->age << endl;
- cout << "Weight: " << this->weight << "g" << endl;
- cout << "Health: " << this->health << "%" << endl;
- cout << "Hunger: " << this->hunger << "%" << endl;
- cout << "Thirst: " << this->thirst << "%" << endl;
- cout << endl;
- }
- void feed()
- {
- cout << "Hunger: " << this->hunger << endl;
- cout << "Thirst: " << this->thirst << endl << endl;
- }
- private:
- void take_color()
- {
- int a = rand() % 6;
- switch (a) {
- case red:
- this->color = "red";
- break;
- case grey:
- this->color = "grey";
- break;
- case black:
- this->color = "black";
- break;
- case white:
- this->color = "white";
- break;
- case browns:
- this->color = "brown";
- break;
- case striped:
- this->color = "striped";
- break;
- }
- }
- void take_eyes()
- {
- int a;
- if (rand() % 20 != 1)
- {
- a = rand() % 6;
- switch (a)
- {
- case blue:
- this->eyes.first = this->eyes.second = "blue";
- break;
- case greys:
- this->eyes.first = this->eyes.second = "grey";
- break;
- case green:
- this->eyes.first = this->eyes.second = "green";
- break;
- case yellow:
- this->eyes.first = this->eyes.second = "yellow";
- break;
- case brown:
- this->eyes.first = this->eyes.second = "brown";
- break;
- case blind:
- this->eyes.first = this->eyes.second = "blind";
- break;
- }
- }
- else
- {
- a = rand() % 6;
- switch (a)
- {
- case blue:
- this->eyes.first = "blue";
- break;
- case greys:
- this->eyes.first = "grey";
- break;
- case green:
- this->eyes.first = "green";
- break;
- case yellow:
- this->eyes.first = "yellow";
- break;
- case brown:
- this->eyes.first = "brown";
- break;
- case blind:
- this->eyes.first = "blind";
- break;
- }
- a = rand() % 6;
- switch (a)
- {
- case blue:
- this->eyes.second = "blue";
- break;
- case greys:
- this->eyes.second = "grey";
- break;
- case green:
- this->eyes.second = "green";
- break;
- case yellow:
- this->eyes.second = "yellow";
- break;
- case brown:
- this->eyes.second = "brown";
- break;
- case blind:
- this->eyes.second = "blind";
- break;
- }
- }
- }
- };
- int main()
- {
- srand(time(NULL));
- Cat first;
- first.rename();
- first.look();
- first.look_health();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement