Advertisement
Norvager

Cats

Dec 19th, 2021
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6.  
  7. enum color { red = 0, grey, black, white, browns, striped };
  8. enum eyes { blue = 0, greys, green, yellow, brown, blind };
  9. enum act { look = 0, add_cat, add_rand_kitten, feed, stroke, play, treat, rename_cat, look_health, kill };
  10. enum food { meat = 0, fish, milk, grass, wet_food };
  11.  
  12. class Cat
  13. {
  14.     int age, weight, health, hunger, thirst;
  15.     string name, color;
  16.     bool gender;
  17.     pair<string, string> eyes;
  18. public:
  19.     Cat()
  20.     {
  21.         this->age = 0;
  22.         this->health = 100;
  23.         this->weight = 100;
  24.         this->hunger = 50;
  25.         this->thirst = 50;
  26.         take_color();
  27.         take_eyes();
  28.         this->gender = true;
  29.         this->name = "Cat";
  30.     }
  31.     Cat(int age, int weight, bool gender, string name)
  32.     {
  33.         this->age = age;
  34.         this->health = 100;
  35.         this->weight = weight;
  36.         this->hunger = 50;
  37.         this->thirst = 50;
  38.         take_color();
  39.         take_eyes();
  40.         this->gender = gender;
  41.         this->name = name;
  42.     }
  43.     void rename()
  44.     {
  45.         cout << "Old name: " << this->name << endl;
  46.         cout << "Would you like change name your cat's?(1=yes, 0=no)" << endl;
  47.         bool a;
  48.         cin >> a;
  49.         if (a)
  50.         {
  51.             cout << "Enter a new name: ";
  52.             cin >> this->name;
  53.             cout << "New name your cat is " << this->name << endl;
  54.         }
  55.         else {
  56.             cout << "Name saved." << endl;
  57.         }
  58.         cout << endl;
  59.     }
  60.     void look()
  61.     {
  62.         cout << "Name your cat's is " << this->name << endl;
  63.         cout << "Wool's color is " << this->color << endl;
  64.         cout << "Left eye is " << this->eyes.first << endl;
  65.         cout << "Right eye is " << this->eyes.second << endl;
  66.         cout << "Age: " << this->age << endl;
  67.         cout << "Weight: " << this->weight << "g" << endl;
  68.         cout << endl;
  69.     }
  70.     void look_health()
  71.     {
  72.         cout << "Name your cat's is " << this->name << endl;
  73.         cout << "Age: " << this->age << endl;
  74.         cout << "Weight: " << this->weight << "g" << endl;
  75.         cout << "Health: " << this->health << "%" << endl;
  76.         cout << "Hunger: " << this->hunger << "%" << endl;
  77.         cout << "Thirst: " << this->thirst << "%" << endl;
  78.         cout << endl;
  79.     }
  80.     void feed()
  81.     {
  82.         cout << "Hunger: " << this->hunger << endl;
  83.         cout << "Thirst: " << this->thirst << endl << endl;
  84.     }
  85. private:
  86.     void take_color()
  87.     {
  88.         int a = rand() % 6;
  89.         switch (a) {
  90.         case red:
  91.             this->color = "red";
  92.             break;
  93.         case grey:
  94.             this->color = "grey";
  95.             break;
  96.         case black:
  97.             this->color = "black";
  98.             break;
  99.         case white:
  100.             this->color = "white";
  101.             break;
  102.         case browns:
  103.             this->color = "brown";
  104.             break;
  105.         case striped:
  106.             this->color = "striped";
  107.             break;
  108.         }
  109.     }
  110.     void take_eyes()
  111.     {
  112.         int a;
  113.         if (rand() % 20 != 1)
  114.         {
  115.             a = rand() % 6;
  116.             switch (a)
  117.             {
  118.             case blue:
  119.                 this->eyes.first = this->eyes.second = "blue";
  120.                 break;
  121.             case greys:
  122.                 this->eyes.first = this->eyes.second = "grey";
  123.                 break;
  124.             case green:
  125.                 this->eyes.first = this->eyes.second = "green";
  126.                 break;
  127.             case yellow:
  128.                 this->eyes.first = this->eyes.second = "yellow";
  129.                 break;
  130.             case brown:
  131.                 this->eyes.first = this->eyes.second = "brown";
  132.                 break;
  133.             case blind:
  134.                 this->eyes.first = this->eyes.second = "blind";
  135.                 break;
  136.             }
  137.         }
  138.         else
  139.         {
  140.             a = rand() % 6;
  141.             switch (a)
  142.             {
  143.             case blue:
  144.                 this->eyes.first = "blue";
  145.                 break;
  146.             case greys:
  147.                 this->eyes.first = "grey";
  148.                 break;
  149.             case green:
  150.                 this->eyes.first = "green";
  151.                 break;
  152.             case yellow:
  153.                 this->eyes.first = "yellow";
  154.                 break;
  155.             case brown:
  156.                 this->eyes.first = "brown";
  157.                 break;
  158.             case blind:
  159.                 this->eyes.first = "blind";
  160.                 break;
  161.             }
  162.             a = rand() % 6;
  163.             switch (a)
  164.             {
  165.             case blue:
  166.                 this->eyes.second = "blue";
  167.                 break;
  168.             case greys:
  169.                 this->eyes.second = "grey";
  170.                 break;
  171.             case green:
  172.                 this->eyes.second = "green";
  173.                 break;
  174.             case yellow:
  175.                 this->eyes.second = "yellow";
  176.                 break;
  177.             case brown:
  178.                 this->eyes.second = "brown";
  179.                 break;
  180.             case blind:
  181.                 this->eyes.second = "blind";
  182.                 break;
  183.             }
  184.         }
  185.     }
  186. };
  187.  
  188. int main()
  189. {
  190.     srand(time(NULL));
  191.     Cat first;
  192.     first.rename();
  193.     first.look();
  194.     first.look_health();
  195.  
  196.     return 0;
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement