#include <iostream>
#include <math.h>
using namespace std;
//电视机类
class Television {
public:
void On() {
cout << "电视机打开...." << endl;
}
void Off() {
cout << "电视机关闭..." << endl;
}
private:
};
//灯类
class Light {
public:
void On() {
cout << "灯打开..." << endl;
}
void Off() {
cout << "灯关闭..." << endl;
}
};
//音响类
class Audio {
public:
void On() {
cout << "音响打开..."<< endl;
}
void Off() {
cout << "音响关闭...." << endl;
}
};
//麦克风
class Mircophone {
public :
void On() {
cout << "麦克风打开..." << endl;
}
void Off() {
cout << "麦克风关闭..." << endl;
}
};
//DVD类
class DVDplayer {
public:
void On() {
cout << "DVD打开..." << endl;
}
void Off() {
cout << "DVD关闭..." << endl;
}
};
//游戏机类
class Gmemachine {
public:
void On() {
cout << "游戏机打开" << endl;
}
void Off() {
cout << "游戏机关闭" << endl;
}
};
//KTV
class KTV {
public:
//构造方法
KTV() {
this->pTV = new Television();
this->pLight = new Light();
this->PAudio = new Audio();
this->pMircophone = new Mircophone();
this->pDVDplayer = new DVDplayer();
}
//打开ktv
void OnKtv() {
pTV->Off();
pLight->On();
PAudio->On();
pMircophone->On();
pDVDplayer->Off();
}
void OffKTV() {
pTV->On();
pLight->Off();
PAudio->Off();
pMircophone->Off();
pDVDplayer->Off();
}
private:
Television* pTV;
Light* pLight;
Audio* PAudio;
Mircophone* pMircophone;
DVDplayer* pDVDplayer;
};
void test() {
//开启Ktv模式
KTV* ktv = new KTV;
ktv->OnKtv();
}
int main()
{
test();
return 0;
}