SHARE
TWEET

Untitled

a guest Nov 15th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. using std::cout;
  4. using std::cin;
  5. using std::endl;
  6. using std::string;
  7. enum typeAnimal {nontype = 0, mammal, reptile, bird, amphibian};
  8. class Animal{
  9.     double mimi = 0;
  10.     int food = 0;
  11. public:
  12.     char* title;
  13.     char* name;
  14.     typeAnimal type_animal;
  15.     int price;
  16.  
  17.     Animal(){
  18.         mimi = 0;
  19.         food = 0;
  20.         title = new char[10];
  21.         name = new char[10];
  22.         strcpy(title,"no name");
  23.         strcpy(name,"no name");
  24.         type_animal = nontype;
  25.         price = 0;
  26.     }
  27.     void set_mimi(double mimi_){
  28.         this->mimi = mimi_;
  29.     }
  30.     void set_food(int f){
  31.         this->food = f;
  32.     }
  33.     double out_mimi() const {
  34.         return mimi;
  35.     }
  36.     int out_food() const{
  37.         return food;
  38.     }
  39.     Animal(const Animal &an){
  40.         int nt = strlen(an.title);
  41.         int nm = strlen(an.name);
  42.         this->title = new char[nt];
  43.         for(int i = 0; i < nt;i++){
  44.             this->title[i] = an.title[i];
  45.         }
  46.         this->name = new char[nm];
  47.         for(int i = 0; i < nm;i++){
  48.             this->name[i] = an.name[i];
  49.         }
  50.     }
  51.     ~Animal(){
  52.        delete[] name;
  53.        delete[] title;
  54.  
  55.     }
  56.     void PrintAnimal();
  57.     //double possitive_effect();
  58. };
  59. void Animal::PrintAnimal() {
  60.     cout << "name: ";
  61.     for(int i = 0; i < strlen(name);i++){
  62.         cout << name[i];
  63.     }
  64.     cout << endl << "title: ";
  65.     for(int i = 0; i < strlen(title);i++){
  66.         cout << title[i];
  67.     }
  68.     cout << endl << "type: ";
  69.     switch (type_animal){
  70.         case nontype:
  71.             cout << "nontype" << endl;
  72.         case reptile:
  73.             cout << "reptile" << endl;
  74.         case bird:
  75.             cout << "bird" << endl;
  76.         case mammal:
  77.             cout << "mammal" << endl;
  78.         case amphibian:
  79.             cout << "amphibian" << endl;
  80.         default:
  81.             cout << "You didn't write a typr" << endl;
  82.     }
  83.     cout << "Price: " << price << endl;
  84.     cout << "Cute :" << mimi << endl;
  85.     cout << "This animal need" << food << "food per day" <<  endl;
  86. }
  87. void indates(Animal &a){
  88.     int n = 0;
  89.     cout << "input title size(count of lattes)";
  90.     cin >> n;
  91.     cout << "input animal's title" << endl;
  92.     a.title = new char[n];
  93.     for(int i = 0; i < n;i++){
  94.         cin >> a.title[i];
  95.     }
  96.     cout << "input name size(count of lattes)";
  97.     cin >> n;
  98.     cout << "input animal's name";
  99.     a.name = new char[n];
  100.     for(int i = 0; i < n;i++){
  101.         cin >> a.name[i];
  102.     }
  103.     cout << "choose animal's type(input number)" << endl;
  104.  
  105.     for(int i = 1; i < 5;i++){
  106.         cout << i << "." << typeAnimal(i) << endl;
  107.     }
  108.     int t = 0;
  109.     cin >> t;
  110.     switch(t) {
  111.         case 1:
  112.             a.type_animal = mammal;
  113.         case 2:
  114.             a.type_animal = reptile;
  115.         case 3:
  116.             a.type_animal = bird;
  117.         case 4:
  118.             a.type_animal = amphibian;
  119.         default:a.type_animal = nontype;
  120.     }
  121.     cout << "input animal's price" << endl;
  122.     cin >> a.price;
  123.     cout << "input his cute(on a scale from 0 to 10)" << endl;
  124.     double c;
  125.     cin >> c;
  126.     a.set_mimi(c);
  127.     cout << "input how much food one need per day" << endl;
  128.     int k;
  129.     cin >> k;
  130.     a.set_food(k);
  131. }
  132. bool is_it_correct(const Animal* a, const char* s){
  133.     int n = strlen(a->name);
  134.     bool flag = true;
  135.     for(int i = 0; i < n;i++){
  136.         if(a->name[i] != s[i]){
  137.             flag = false;
  138.             break;
  139.         }
  140.     }
  141.     return flag;
  142. }
  143.  
  144.  
  145. int main() {
  146.     Animal a;
  147.  
  148.     std::cout << "Hello, World!" << std::endl;
  149.     return 0;
  150. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top