Chinaunix首页 | 论坛 | 博客
  • 博客访问: 97891
  • 博文数量: 46
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 505
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-22 19:56
文章分类
文章存档

2008年(46)

我的朋友

分类: C/C++

2008-11-11 21:59:58

门面模式将多个同级的类进行屏蔽,为多个类给出一个公共的界面,提供给外部程序使用
class CCustomer
{
public:
       string m_name;
       CCustomer(string & s_name)
       {
        m_name = s_name;
       }
} ;

class CBank
{
public:
       bool SufficentSavings(CCustomer & c)
       {
        cout << "check customer:" << c.m_name << "'s sufficentsaving."<<endl;
        return true;
       }
};


class CCredit
{
public:
       bool checkCredit(CCustomer & c)
       {
        cout << "check customer:" << c.m_name << "'s Credit."<<endl;
        return true;
       }
};


class CLoan
{
public:
       bool checkLoan(CCustomer & c)
       {
        cout << "check customer:" << c.m_name << "'s Loan."<<endl;
        return true;
       }
};

class CFacadeMortgage
{
public:

       bool debit(string& s)
       {
        m_pcust = new CCustomer(s);
        m_pbank = new CBank();
        if (!m_pbank->SufficentSavings(*m_pcust))
           return false;


        m_ploan = new CLoan();

        if (!m_ploan->checkLoan(*m_pcust))
           return false;


            m_pcredit = new CCredit();
        if (! m_pcredit->checkCredit(*m_pcust))
           return false;
        return true;
       }
private:
     CBank* m_pbank;
     CCustomer* m_pcust;
     CLoan* m_ploan;
     CCredit* m_pcredit;

} ;

int main(int argc, char* argv[])
{
    CFacadeMortgage d;
    d.debit("ss");
    getch();

    return 0;
}

阅读(780) | 评论(0) | 转发(0) |
0

上一篇:设计模式之装饰模式

下一篇:win32 多线程

给主人留下些什么吧!~~