外观模式为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这个子系统更加容易使用
#include "stdafx.h"
#include<iostream>
using namespace std;
class SubSystemOne
{
public:
void MethodOne()
{
cout<<" this is system one "<<endl;
}
};
class SubSystemTwo
{
public:
void MethodTwo()
{
cout<<" this is system two "<<endl;
}
};
class SubSystemThree
{
public:
void MethodThree()
{
cout<<" this is system three "<<endl;
}
};
class SubSystemFour
{
public:
void MethodFour()
{
cout<<" this is system four "<<endl;
}
};
class Facade
{
public:
Facade()
{
_one = new SubSystemOne();
_two = new SubSystemTwo();
_three = new SubSystemThree();
_four = new SubSystemFour();
}
void MethorA()
{
_one->MethodOne();
_two->MethodTwo();
}
void MethorB()
{
_three->MethodThree();
_four->MethodFour();
}
private:
SubSystemOne *_one;
SubSystemTwo *_two;
SubSystemThree *_three;
SubSystemFour * _four;
};
// FacadeMode.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include"Facade.hpp"
int _tmain(int argc, _TCHAR* argv[])
{
Facade *facade = new Facade();
facade->MethorA();
facade->MethorB();
system("pause:");
return 0;
}