Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Boss
- {
- private:
- string name;
- int health;
- bool isFinal;
- string abilities;
- public:
- static int countFinal, countNotFinal;
- bool isCorrect()
- {
- if (health >= 1e5 && health <= 1e7) return true;
- return false;
- }
- Boss() == default;
- Boss(const Boss& b)
- {
- this->name = b.name;
- this->health = b.health;
- this->isFinal = b.isFinal;
- this->abilities = b.abilities;
- }
- Boss(string name, int health, bool isFinal, string abilities)
- {
- if (isFinal) countFinal++;
- else countNotFinal++;
- this->name = name;
- if (isCorrect()) this->health = health;
- else this->health = 1e5;
- this->isFinal = isFinal;
- this->abilities = abilities;
- }
- void setName(string name)
- {
- this->name = name;
- }
- void setHealth(int health)
- {
- this->health = health;
- }
- void setIsFinal(bool isFinal)
- {
- if (isFinal) countFinal++;
- else countNotFinal++;
- this->isFinal = isFinal;
- }
- void setAbilities(string abilities)
- {
- this->abilities = abilities;
- }
- friend bool operator==(const Boss& b)
- {
- if (this->isFinal() && b.isFinal() || !this->isFinal() && !b.isFinal())
- {
- if (this->health == b.health)
- {
- if (this->abilities.length() == b.abilities.length())
- {
- return true;
- }
- }
- }
- return false;
- }
- friend bool operator<(const Boss& b)
- {
- if (!this->isFinal && b.isFinal) return true;
- else if ((this->isFinal && b.isFinal || !this->isFinal && !b.isFinal) && this->health < b.health) return true;
- else if (this->health == b.health && this->abilities.length() < b.abilities.length()) return true;
- return false;
- }
- friend ostream& operator<<(ostream& out, const Boss& b)
- {
- out << b.name << " " << b.health << " " << (b.isFinal ? "true" : "false") << endl;
- out << b.abilities << endl << endl;
- }
- };
- int Boss::countFinal = 0, Boss::countNotFinal = 0;
- int main()
- {
- string name, abilities;
- int health;
- bool isFinal;
- Boss b1("pasha", 1e7 - 23, true, "he's very strong"), b2(b1);
- Boss b3("rauf", 1e7 + 1000, false, "he's trying to cheat with health.");
- cout << (b1 == b2) << " " << (b1 < b2) << " " << (b2 < b3) << " " << (b1 == b3);
- cout << Boss::countFinal << " " << Boss:countNotFinal;
- cout << b1 << b2 << b3;
- return 0;
- }
Add Comment
Please, Sign In to add comment