Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- using namespace std;
- class River
- {
- private:
- static int RavnCount;
- static int GornCount;
- string name;
- int length;
- string type;
- string countries;
- public:
- River()
- {
- this->name = "";
- this->length = 0;
- this->type = "равнинная";
- this->countries = "";
- }
- River(const River& riv)
- {
- this->name = riv.name;
- this->length = riv.length;
- this->type = riv.type;
- this->countries = riv.countries;
- }
- River(string name, int length, string type, string countries)
- {
- this->name = name;
- this->length = length;
- if (type != "равнинная" || type != "горная")
- {
- this->type = type;
- }
- else
- {
- this->type = "равнинная";
- }
- this->countries = countries;
- }
- void setName(string name)
- {
- this->name = name;
- }
- void setLength(int length)
- {
- this->length = length;
- }
- void setType(string type)
- {
- if (type != "равнинная" || type != "горная")
- {
- this->type = type;
- }
- else
- {
- this->type = "равнинная";
- }
- }
- void setCountries(string countries)
- {
- this->countries = countries;
- }
- string getName()
- {
- return this->name;
- }
- int getLength()
- {
- return this->length;
- }
- string getType()
- {
- return this->type;
- }
- string getCountries()
- {
- return this->countries;
- }
- void Show()
- {
- cout << getName() << " " << getLength() << " " << getType() << " " << getCountries() << endl;
- }
- bool operator>(const River& riv)
- {
- if (this->type > riv.type)
- {
- return true;
- }
- else if (this->type == riv.type && this->length < riv.length)
- {
- return true;
- }
- else if (this->length == riv.length && this->name > riv.name)
- {
- return true;
- }
- return false;
- }
- bool operator==(const River& riv)
- {
- if (this->type == riv.type && this->length == riv.length && this->name == riv.name && this->countries == riv.countries)
- {
- return true;
- }
- return false;
- }
- };
- int River::RavnCount = 0;
- int River::GornCount = 0;
- int main()
- {
- setlocale(LC_ALL, "rus");
- River riv1, riv2("Volga", 1000, "равнинная", "Россия"), riv3("Ashe", 500, "горная", "Россия");
- riv1.Show();
- riv1.setName("Volga");
- riv1.setLength(1000);
- riv1.setType("равнинная");
- riv1.setCountries("Россия");
- riv1.Show();
- riv2.Show();
- riv3.Show();
- cout << (riv1 == riv2) << " " << (riv2 > riv3) << " " << (riv3 > riv1) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement