Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #include<string>
  2. #include "stdafx.h"
  3. #include <iostream>
  4. using namespace std;
  5. class Screen
  6. {
  7. private:
  8. string firm;
  9. int resolution;
  10. int price;
  11. bool auto_turn;
  12. friend class Phone;
  13. public:
  14. // Default constructor
  15. Screen(string firm = "Samsung", int resolution = 1080, int price = 1000,
  16. bool auto_turn = true) :
  17. auto_turn(auto_turn), firm(firm)
  18. {
  19. this->resolution = resolution;
  20. this->price = price;
  21. }
  22. // Copy constructor
  23. Screen(const Screen &screen)
  24. {
  25. this->firm = screen.firm;
  26. this->resolution = screen.resolution;
  27. this->price = screen.price;
  28. }
  29. void options()
  30. {
  31. cout << "Информация об экране:" << endl
  32. << "Фирма: " << firm << endl
  33. << "Разрешение: " << resolution << endl
  34. << "Цена: " << price << endl;
  35. }
  36. // Destructor
  37. ~Screen()
  38. {};
  39. };
  40.  
  41. class Phone {
  42. public: Phone(Screen screen, int price, int num_sims, bool memory_slot, string firm)
  43. : screen(screen), price(price), num_sims(num_sims), memory_slot(memory_slot), firm(firm)
  44. { }
  45. void download_serial()
  46. {
  47. if (memory_slot)
  48. {
  49. cout << "выберите сериал для скачивания" << endl << endl;
  50. }
  51. else
  52. cout << "недостаточно памяти" << endl << endl;
  53. }
  54. void visualisation_of_the_phone()
  55. {
  56. cout << "ИНФОРМАЦИЯ О ТЕЛЕФОНЕ: " << endl
  57. << "Цена(руб): " << price << endl
  58. << "Количество сим-карт: " << num_sims << endl
  59. << "Есть слот для карты памяти: " << (memory_slot ? "Да" : "Нет") << endl
  60. << "Фирма: " << firm << endl
  61. << "Экран поддерживает автоповорот: " << (screen.auto_turn ? "Да" : "Нет")
  62. << endl << "Разрешение: " << screen.resolution << endl;
  63. screen.options();
  64. }
  65. private:
  66. int price;
  67. int num_sims;
  68. bool memory_slot;
  69. string firm;
  70. Screen screen;
  71. friend void change_price(Phone &obj);
  72. };
  73. void change_price(Phone &obj)
  74. {
  75. obj.price = 80000;
  76. }
  77. int main()
  78. {
  79. setlocale(LC_ALL, "Russian");
  80. Screen screen("Samsung", 1080, true);
  81. Phone phone(screen, 8000, 2, false, "Apple");
  82. change_price(phone);
  83. phone.download_serial();
  84. phone.visualisation_of_the_phone();
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement