Advertisement
MARSHAL327

Untitled

Jan 9th, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class seed {
  5.     int _grow;
  6. public:
  7.     seed() {
  8.         _grow = 0;
  9.     }
  10.  
  11.     ~seed() {
  12.         _grow = 0;
  13.     }
  14.  
  15.     void grow() {
  16.         cout << "seed" << endl;
  17.         _grow++;
  18.     }
  19.  
  20.     bool fresh() {
  21.         if (_grow < 5) {
  22.             return true;
  23.         }
  24.         else return false;
  25.     }
  26.  
  27.     void seed_print() {
  28.         cout << "seed" << endl;
  29.         cout << _grow << endl;
  30.         cout << fresh() << endl;
  31.     }
  32. };
  33.  
  34. class plant :public seed {
  35.     int grow_plant, oxygen;
  36. public:
  37.     plant() {
  38.         grow_plant = 0;
  39.         oxygen = 0;
  40.     }
  41.  
  42.     ~plant() {
  43.         grow_plant = 0;
  44.         oxygen = 0;
  45.     }
  46.  
  47.     void grow() {
  48.         cout << "plant" << endl;
  49.         grow_plant++;
  50.     }
  51.  
  52.     void print() {
  53.         cout << "plant" << endl;
  54.         cout << grow_plant << "  " << oxygen << endl;
  55.     }
  56.  
  57.     void plant_oxygen() {
  58.         oxygen = grow_plant * 2;
  59.     }
  60. };
  61.  
  62.  
  63.  
  64.  
  65.  
  66. int main() {
  67.     plant P;
  68.     P.print();
  69.  
  70.     P.grow();
  71.     P.grow();
  72.     P.grow();
  73.     P.grow();
  74.     P.grow();
  75.     P.plant_oxygen();
  76.  
  77.     P.print();
  78.     P.seed_print();
  79.    
  80.  
  81.     return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement