#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
//Structural Patterns--Facade
//结构型模式--外观模式
//Facade(外观):模式的核心,被 Client 调用,知晓相关子系统的功能和责任。在正常情况下,它将所有从 Client 发来的请求委派到相应的子系统去,让子系统处理。
//SubSystem(子系统):可以同时有一个或者多个子系统,子系统可以是一个单独的类或类的集合。每个子系统都可以被 Client 直接调用,或者被 Facade 调用,
// 它处理由 Facade 传过来的请求。子系统并不知道 Facade 的存在,对于子系统而言,Facade 仅仅是另外一个 Client 而已。
class Cpu
{
public:
void ProductCpu(){cout << "Product Cpu." << endl;}
};
class Ram
{
public:
void ProductRam(){cout << "Product Ram." << endl;}
};
class Graphics
{
public:
void ProductGraphics(){cout << "Product CpuGraphics." << endl;}
};
class Computer
{
public:
void ProductComputer()
{
Cpu c;
c.ProductCpu();
Ram r;
r.ProductRam();
Graphics g;
g.ProductGraphics();
}
};
void dpFacadeTestMain()
{
Computer computer;
computer.ProductComputer();
Cpu c;
c.ProductCpu();
return;
}