MasterGun

TV operations

Mar 21st, 2020 (edited)
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class TV {
  5.  
  6.     int height;
  7.     int width;
  8.     int screen_size;
  9.     int channel;
  10.     int volume;
  11.     bool power = false;
  12.  
  13.  
  14. public:
  15.     TV(int _height, int _width, int _screen_size, int _channel) {
  16.  
  17.         height = _height;
  18.         width = _width;
  19.         screen_size = _screen_size;
  20.         channel = _channel;
  21.         volume = 0;
  22.         power = 0;
  23.     }
  24.  
  25.     void SetPower(int a) {
  26.         if (a == 1) {
  27.             power = true;
  28.             cout << "TV is on" <<endl;
  29.         }
  30.         else if (a == 0) {
  31.  
  32.             power = false;
  33.             cout << "TV is off" << endl;
  34.         }
  35.         else {
  36.             cout << "ERROR 404 Command Not Found" << endl;
  37.         }
  38.     }
  39.     void SetChannel(int b) {
  40.  
  41.         if (b < 7 ) {
  42.  
  43.             cout << "You are on channel" <<"  "<<b << endl;
  44.  
  45.         }
  46.         else {
  47.  
  48.             cout << "Channel doesn't exist" << endl;
  49.  
  50.         }
  51.         }
  52.     void SetVolume(int c) {
  53.  
  54.         if (c == 1) {
  55.  
  56.             volume++;
  57.             cout << volume << endl;
  58.  
  59.         }
  60.         else if (c = 0, volume > 0) {
  61.             volume--;
  62.             cout << volume << endl;
  63.         }
  64.  
  65.     }
  66.  
  67. };
  68. int main(){
  69.     int a;
  70.     cin >> a;
  71.     int b;
  72.     cin >> b;
  73.     int c;
  74.     cin >> c;
  75.  
  76.     TV TV1(28,15,30,b);
  77.     TV1.SetPower(a);
  78.     TV1.SetVolume(c);
  79.     TV1.SetChannel(b);
  80.  
  81. system("pause");
  82. return 0;
  83. }
Add Comment
Please, Sign In to add comment