Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "computer_info.h"
- Computer::Computer(string firm, string mark, int yearB)
- {
- this->firm = firm;
- this->mark = mark;
- this->yearB = yearB;
- }
- Desktop::Desktop(string firm, string mark, int yearB, int power) : Computer(firm, mark, yearB)
- {
- this->power = power;
- }
- Laptop::Laptop(string firm, string mark, int yearB, int core) : Computer(firm, mark, yearB)
- {
- this->core = core;
- }
- void Computer::changeY(int yearB)
- {
- this->yearB = yearB;
- }
- void Computer::changeM(string mark)
- {
- this->mark = mark;
- }
- void Computer::changeF(string firm)
- {
- this->firm = firm;
- }
- void Desktop::changeP(int power)
- {
- this->power = power;
- }
- void Laptop::changeC(int core)
- {
- this->core = core;
- }
- string Computer::print()
- {
- return this->firm + " " + this->mark + " " + to_string(yearB) + "\n";
- }
- string Desktop::print(int current_year)
- {
- if (current_year < this->yearB)
- {
- return this->firm + " " + this->mark + " Еще не выпущен " + to_string(this->power) + "\n";
- }
- if (current_year - this->yearB > 5)
- {
- return this->firm + " " + this->mark + " Устарел " + to_string(this->power) + "\n";
- }
- if (current_year - this->yearB < 5)
- {
- return this->firm + " " + this->mark + " " + to_string(current_year - this->yearB) + " " + to_string(this->power) + "\n";
- }
- }
- string Laptop::print(int current_year)
- {
- if (current_year < this->yearB)
- {
- return this->firm + " " + this->mark + " Еще не выпущен " + to_string(this->core) + "\n";
- }
- if (current_year - this->yearB > 5)
- {
- return this->firm + " " + this->mark + " Устарел " + to_string(this->core) + "\n";
- }
- if (current_year - this->yearB < 5)
- {
- return this->firm + " " + this->mark + " " + to_string(current_year - this->yearB) + " " + to_string(this->core) + "\n";
- }
- }
Add Comment
Please, Sign In to add comment