Advertisement
awsmpshk

Untitled

Nov 25th, 2020 (edited)
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.04 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. class River
  7. {
  8. private:
  9.     static int RavnCount;
  10.     static int GornCount;
  11.     string name;
  12.     int length;
  13.     string type;
  14.     string countries;
  15. public:
  16.     River()
  17.     {
  18.         this->name = "";
  19.         this->length = 0;
  20.         this->type = "равнинная";
  21.         this->countries = "";
  22.     }
  23.    
  24.     River(const River& riv)
  25.     {
  26.         this->name = riv.name;
  27.         this->length = riv.length;
  28.         this->type = riv.type;
  29.         this->countries = riv.countries;
  30.     }
  31.    
  32.     River(string name, int length, string type, string countries)
  33.     {
  34.         this->name = name;
  35.         this->length = length;
  36.         if (type != "равнинная" || type != "горная")
  37.         {
  38.             this->type = type;
  39.         }
  40.         else
  41.         {
  42.             this->type = "равнинная";
  43.         }
  44.         this->countries = countries;
  45.     }
  46.    
  47.     void setName(string name)
  48.     {
  49.         this->name = name;
  50.     }
  51.    
  52.     void setLength(int length)
  53.     {
  54.         this->length = length;
  55.     }
  56.    
  57.     void setType(string type)
  58.     {
  59.         if (type != "равнинная" || type != "горная")
  60.         {
  61.             this->type = type;
  62.         }
  63.         else
  64.         {
  65.             this->type = "равнинная";
  66.         }
  67.     }
  68.    
  69.     void setCountries(string countries)
  70.     {
  71.         this->countries = countries;
  72.     }
  73.    
  74.     string getName()
  75.     {
  76.         return this->name;
  77.     }
  78.    
  79.     int getLength()
  80.     {
  81.         return this->length;
  82.     }
  83.    
  84.     string getType()
  85.     {
  86.         return this->type;
  87.     }
  88.    
  89.     string getCountries()
  90.     {
  91.         return this->countries;
  92.     }
  93.    
  94.     void Show()
  95.     {
  96.         cout << getName() << " " << getLength() << " " << getType() << " " << getCountries() << endl;
  97.     }
  98.    
  99.     bool operator>(const River& riv)
  100.     {
  101.         if (this->type > riv.type)
  102.         {
  103.             return true;
  104.         }
  105.         else if (this->type == riv.type && this->length < riv.length)
  106.         {
  107.             return true;
  108.         }
  109.         else if (this->length == riv.length && this->name > riv.name)
  110.         {
  111.             return true;
  112.         }
  113.         return false;
  114.     }
  115.    
  116.     bool operator==(const River& riv)
  117.     {
  118.         if (this->type == riv.type && this->length == riv.length && this->name == riv.name && this->countries == riv.countries)
  119.         {
  120.             return true;
  121.         }
  122.         return false;
  123.     }
  124. };
  125.  
  126. int River::RavnCount = 0;
  127. int River::GornCount = 0;
  128.  
  129. int main()
  130. {
  131.     setlocale(LC_ALL, "rus");
  132.     River riv1, riv2("Volga", 1000, "равнинная", "Россия"), riv3("Ashe", 500, "горная", "Россия");
  133.     riv1.Show();
  134.     riv1.setName("Volga");
  135.     riv1.setLength(1000);
  136.     riv1.setType("равнинная");
  137.     riv1.setCountries("Россия");
  138.     riv1.Show();
  139.     riv2.Show();
  140.     riv3.Show();
  141.     cout << (riv1 == riv2) << " " << (riv2 > riv3) << " " << (riv3 > riv1) << endl;
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement