Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class TV {
- int height;
- int width;
- int screen_size;
- int channel;
- int volume;
- bool power = false;
- public:
- TV(int _height, int _width, int _screen_size, int _channel) {
- height = _height;
- width = _width;
- screen_size = _screen_size;
- channel = _channel;
- volume = 0;
- power = 0;
- }
- void SetPower(int a) {
- if (a == 1) {
- power = true;
- cout << "TV is on" <<endl;
- }
- else if (a == 0) {
- power = false;
- cout << "TV is off" << endl;
- }
- else {
- cout << "ERROR 404 Command Not Found" << endl;
- }
- }
- void SetChannel(int b) {
- if (b < 7 ) {
- cout << "You are on channel" <<" "<<b << endl;
- }
- else {
- cout << "Channel doesn't exist" << endl;
- }
- }
- void SetVolume(int c) {
- if (c == 1) {
- volume++;
- cout << volume << endl;
- }
- else if (c = 0, volume > 0) {
- volume--;
- cout << volume << endl;
- }
- }
- };
- int main(){
- int a;
- cin >> a;
- int b;
- cin >> b;
- int c;
- cin >> c;
- TV TV1(28,15,30,b);
- TV1.SetPower(a);
- TV1.SetVolume(c);
- TV1.SetChannel(b);
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment