Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<string>
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- class Screen
- {
- private:
- string firm;
- int resolution;
- int price;
- bool auto_turn;
- friend class Phone;
- public:
- // Default constructor
- Screen(string firm = "Samsung", int resolution = 1080, int price = 1000,
- bool auto_turn = true) :
- auto_turn(auto_turn), firm(firm)
- {
- this->resolution = resolution;
- this->price = price;
- }
- // Copy constructor
- Screen(const Screen &screen)
- {
- this->firm = screen.firm;
- this->resolution = screen.resolution;
- this->price = screen.price;
- }
- void options()
- {
- cout << "Информация об экране:" << endl
- << "Фирма: " << firm << endl
- << "Разрешение: " << resolution << endl
- << "Цена: " << price << endl;
- }
- // Destructor
- ~Screen()
- {};
- };
- class Phone {
- public: Phone(Screen screen, int price, int num_sims, bool memory_slot, string firm)
- : screen(screen), price(price), num_sims(num_sims), memory_slot(memory_slot), firm(firm)
- { }
- void download_serial()
- {
- if (memory_slot)
- {
- cout << "выберите сериал для скачивания" << endl << endl;
- }
- else
- cout << "недостаточно памяти" << endl << endl;
- }
- void visualisation_of_the_phone()
- {
- cout << "ИНФОРМАЦИЯ О ТЕЛЕФОНЕ: " << endl
- << "Цена(руб): " << price << endl
- << "Количество сим-карт: " << num_sims << endl
- << "Есть слот для карты памяти: " << (memory_slot ? "Да" : "Нет") << endl
- << "Фирма: " << firm << endl
- << "Экран поддерживает автоповорот: " << (screen.auto_turn ? "Да" : "Нет")
- << endl << "Разрешение: " << screen.resolution << endl;
- screen.options();
- }
- private:
- int price;
- int num_sims;
- bool memory_slot;
- string firm;
- Screen screen;
- friend void change_price(Phone &obj);
- };
- void change_price(Phone &obj)
- {
- obj.price = 80000;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- Screen screen("Samsung", 1080, true);
- Phone phone(screen, 8000, 2, false, "Apple");
- change_price(phone);
- phone.download_serial();
- phone.visualisation_of_the_phone();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement