Advertisement
kirill_76rus

facade

Apr 23rd, 2020
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include<math.h>
  3. using namespace std;
  4.  
  5. class desktop
  6. {
  7. public:
  8.     void on() {
  9.         cout << "power on\n";
  10.     }
  11.     void off() {
  12.         cout << "power off\n";
  13.     }
  14.     void notebook() {
  15.         cout << "open notebook\n";
  16.     }
  17.     void sum() {
  18.         int a, b;
  19.         cin >> a >> b;
  20.         cout << a + b<<'\n';
  21.     }
  22.     void sqr() {
  23.         int i;
  24.         cin >> i;
  25.         cout << sqrt(i);
  26.  
  27.     }
  28. };
  29.  
  30.  
  31. class Facade
  32. {
  33. public:
  34.    
  35.     desktop cur;
  36.     void operation() {
  37.         cout << "0-power on\n 1 - sum\n 2 - sqrt\n 3 - notebook\n 4 - power off\n";
  38.         int status;
  39.         cin >> status;
  40.         if (status == 0)
  41.             cur.on();
  42.         if (status == 1)
  43.             cur.sum();
  44.         if (status == 2)
  45.             cur.sqr();
  46.         if (status == 3)
  47.             cur.notebook();
  48.         if (status == 4)
  49.             cur.off();
  50.     }
  51. };
  52.  
  53. int main()
  54. {
  55.     while (1) {
  56.         Facade PC;
  57.         PC.operation();
  58.     }
  59.    
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement