门面(Facade)模式

一、 门面(Facade)模式

@【Facade模式】

Facade模式-门面模式的作用是

(1)为复杂的系统提供一个简单的接口

(2)将子系统和调用者或称客户相分离

(3)层次化的结构,减少层之间的依赖。

 

【图解】以病人去门诊治疗子系统(只简单的列出一个子系统)为例:

 1

 

 

 

#ifndef FACADE_WAITER_H_
#define FACADE_WAITER_H_


class Registe;
class Diagnose;
class Assay;
class Medicine;

//接待员
class FacadeWaiter
{
public:
 FacadeWaiter();
 virtual~ FacadeWaiter();
 virtual void ReceiveClient();
private:
 Registe*  m_pRegiste;
 Diagnose* m_pDiagnose;
 Assay*    m_pAssay;
 Medicine* m_pMedicine;
};

#endif

#ifndef REGISTE_H_
#define REGISTE_H_
#include <iostream>

using namespace std;

class Registe
{
public:
 void Start()
 { 
  cout<<" Registe 挂号Start "<<endl;
 }
 void End()
 {
  cout<<" Registe 挂号 End"<<endl;

 }
};

#endif

 

#ifndef DIAGNOSE_H_
#define DIAGNOSE_H_

#include "stdafx.h"
#include <iostream>

using namespace std;

class Diagnose
{
public:
 void Start()
 { 
  cout<<" Diagnose 就诊 Start "<<endl;
 }
 void End()
 {
  cout<<" Diagnose 就诊  End"<<endl;

 }
};

#endif

 

#ifndef ASSAY_H_
#define ASSAY_H_
#include "stdafx.h"

#include <iostream>

using namespace std;

class Assay
{
public:
 void Start()
 { 
  cout<<" Assay 化验 Start "<<endl;
 }
 void End()
 {
  cout<<" Assay 化验  End"<<endl;

 }
};

#endif

#ifndef MEDICINE_H_
#define MEDICINE_H_
#include "stdafx.h"

#include <iostream>

using namespace std;

class Medicine
{
public:
 void Start()
 { 
  cout<<" Medicine 取药 Start "<<endl;
 }
 void End()
 {
  cout<<" Medicine 取药  End"<<endl;

 }
};

#endif

#include "stdafx.h"
#include "FacadeWaiter.h"
#include "Registe.h"//挂号
#include "Diagnose.h"//就诊
#include "Assay.h"//化验
#include "Medicine.h"//取药


FacadeWaiter::FacadeWaiter()
{
 m_pRegiste = new Registe;
 m_pDiagnose = new Diagnose;
 m_pAssay = new Assay;
 m_pMedicine = new Medicine;
}

FacadeWaiter::~FacadeWaiter()
{
 delete m_pRegiste;
 m_pRegiste = NULL;

 delete m_pDiagnose;
 m_pDiagnose = NULL;

 delete m_pAssay;
 m_pAssay = NULL;

 delete m_pMedicine;
 m_pMedicine = NULL;
}

void FacadeWaiter::ReceiveClient()
{
 m_pRegiste->Start();
 m_pRegiste->End();

 m_pDiagnose->Start();
 m_pDiagnose->End();

 m_pAssay->Start();
 m_pAssay->End();

 m_pMedicine->Start();
 m_pMedicine->End();
}

 


#include "stdafx.h"
#include "FacadeWaiter.h"
#include <stdlib.h>

int _tmain(int argc, _TCHAR* argv[])
{
 FacadeWaiter* lpFacadeWaiter = new FacadeWaiter;
 lpFacadeWaiter->ReceiveClient();
 
 delete lpFacadeWaiter;
 lpFacadeWaiter = NULL;
 
 system("pause");
 return 0;
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

转的 http://blog.csdn.net/roynee/article/details/4578626

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值