fferum

computer_info.cpp

Nov 7th, 2020 (edited)
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #include "computer_info.h"
  2. Computer::Computer(string firm, string mark, int yearB)
  3. {
  4.     this->firm = firm;
  5.     this->mark = mark;
  6.     this->yearB = yearB;
  7. }
  8. Desktop::Desktop(string firm, string mark, int yearB, int power) : Computer(firm, mark, yearB)
  9. {
  10.     this->power = power;
  11. }
  12. Laptop::Laptop(string firm, string mark, int yearB, int core) : Computer(firm, mark, yearB)
  13. {
  14.     this->core = core;
  15. }
  16. void Computer::changeY(int yearB)
  17. {
  18.     this->yearB = yearB;
  19. }
  20. void Computer::changeM(string mark)
  21. {
  22.     this->mark = mark;
  23. }
  24. void Computer::changeF(string firm)
  25. {
  26.     this->firm = firm;
  27. }
  28. void Desktop::changeP(int power)
  29. {
  30.     this->power = power;
  31. }
  32. void Laptop::changeC(int core)
  33. {
  34.     this->core = core;
  35. }
  36. string Computer::print()
  37. {
  38.     return this->firm + " " + this->mark + " " + to_string(yearB) + "\n";
  39. }
  40. string Desktop::print(int current_year)
  41. {
  42.     if (current_year < this->yearB)
  43.     {
  44.         return this->firm + " " + this->mark + " Еще не выпущен " + to_string(this->power) + "\n";
  45.     }
  46.     if (current_year - this->yearB > 5)
  47.     {
  48.         return this->firm + " " + this->mark + " Устарел " + to_string(this->power) + "\n";
  49.     }
  50.     if (current_year - this->yearB < 5)
  51.     {
  52.         return this->firm + " " + this->mark + " " + to_string(current_year - this->yearB) + " " + to_string(this->power) + "\n";
  53.     }
  54. }
  55. string Laptop::print(int current_year)
  56. {
  57.     if (current_year < this->yearB)
  58.     {
  59.         return this->firm + " " + this->mark + " Еще не выпущен " + to_string(this->core) + "\n";
  60.     }
  61.     if (current_year - this->yearB > 5)
  62.     {
  63.         return this->firm + " " + this->mark + " Устарел " + to_string(this->core) + "\n";
  64.     }
  65.     if (current_year - this->yearB < 5)
  66.     {
  67.         return this->firm + " " + this->mark + " " + to_string(current_year - this->yearB) + " " + to_string(this->core) + "\n";
  68.     }
  69. }
Add Comment
Please, Sign In to add comment