#include <iostream>
using namespace std;
class DaFa
{
public:
virtual void Show() = 0;
};
class DaFa_Phone : public DaFa
{
public:
void Show()
{
cout<< "I'm DaFa_Phone"<<endl;
}
};
class DaFa_TV : public DaFa
{
public:
void Show()
{
cout<< "I'm DaFa_TV"<<endl;
}
};
class DaMi
{
public:
virtual void Show() = 0;
};
class DaMi_Phone : public DaMi
{
public:
void Show()
{
cout<< "I'm DaMi_Phone"<<endl;
}
};
class DaMi_TV : public DaMi
{
public:
void Show()
{
cout<< "I'm DaMi_TV"<<endl;
}
};
class Nuojiya
{
public:
virtual void Show() = 0;
};
class Nuojiya_Phone : public Nuojiya
{
public:
void Show()
{
cout<< "I'm Nuojiya_Phone"<<endl;
}
};
class Nuojiya_TV : public Nuojiya
{
public:
void Show()
{
cout<< "I'm Nuojiya_TV"<<endl;
}
};
class Nuojiya_Brick:public Nuojiya
{
public:
void Show()
{
cout<< "I'm Nuojiya_Brick"<<endl;
}
};
class Futukang
{
private:
char item;
public:
Futukang(char _item){item=_item;}
DaFa* CreateDaFa(){
DaFa* result=NULL;
switch(item){
case 'P':
result=new DaFa_Phone;
break;
case 'T':
result=new DaFa_TV;
break;
}
return result;
}
DaMi* CreateDaMi(){
DaMi* result=NULL;
switch(item){
case 'P':
result=new DaMi_Phone;
break;
case 'T':
result=new DaMi_TV;
break;
}
return result;
}
Nuojiya* CreateNuojiya(){
Nuojiya* result=NULL;
switch(item){
case 'P':
result=new Nuojiya_Phone;
break;
case 'T':
result=new Nuojiya_TV;
break;
case'B':
result=new Nuojiya_Brick;
break;
}
return result;
}
};
int main(int argc , char *argv [])
{
Futukang phone=Futukang('P');
Futukang tv=Futukang('T');
Futukang brick=Futukang('B');
DaFa* dafa_phone=phone.CreateDaFa();
DaFa* dafa_tv=tv.CreateDaFa();
DaMi* dami_phone=phone.CreateDaMi();
DaMi* dami_tv=tv.CreateDaMi();
Nuojiya* nuojiya_phone=phone.CreateNuojiya();
Nuojiya* nuojiya_tv=tv.CreateNuojiya();
Nuojiya* nuojiya_brick=brick.CreateNuojiya();
dafa_phone->Show();
dafa_tv->Show();
dami_phone->Show();
dami_tv->Show();
nuojiya_phone->Show();
nuojiya_tv->Show();
nuojiya_brick->Show();
return 0;
}