外观模式
为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一子系统更加容易使用。
为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一子系统更加容易使用。
#include<iostream>
using namespace std;
class SubSystemOne
{
public:
void MethodOne()
{
cout<<"system method 1 "<<endl;
}
};
class SubSystemTwo
{
public:
void MethodTwo()
{
cout<<"system method 2 "<<endl;
}
};
class SubSystemThree
{
public:
void MethodThree()
{
cout<<"system method 3 "<<endl;
}
};
class SubSystemFour
{
public:
void MethodFour()
{
cout<<"system method 4 "<<endl;
}
};
class Facade
{
SubSystemOne *one;
SubSystemTwo *two;
SubSystemThree *three;
SubSystemFour *four;
public:
Facade()
{
one = new SubSystemOne();
two = new SubSystemTwo();
three = new SubSystemThree();
four = new SubSystemFour();
}
void MethodA()
{
cout<<"method a..."<<endl;
one->MethodOne();
two->MethodTwo();
}
void MethodB()
{
cout<<"method b..."<<endl;
three->MethodThree();
four->MethodFour();
}
};
int main()
{
Facade *facade = new Facade();
facade->MethodA();
facade->MethodB();
return 0;
}