添加设计模式及例子,包括:单例、抽象工厂、适配器、桥接、观察者模式

This commit is contained in:
huihut
2018-07-22 14:50:54 +08:00
parent 92bc715c1f
commit b69685a5a7
31 changed files with 839 additions and 31 deletions

View File

@@ -0,0 +1,25 @@
//
// Created by xiemenghui on 2018/7/20.
//
#include "Factory.h"
#include "concrete_factory.h"
Factory* Factory::CreateFactory(FACTORY_TYPE factory)
{
Factory *pFactory = nullptr;
switch (factory) {
case FACTORY_TYPE::BENZ_FACTORY: // 奔驰工厂
pFactory = new BenzFactory();
break;
case FACTORY_TYPE::BMW_FACTORY: // 宝马工厂
pFactory = new BmwFactory();
break;
case FACTORY_TYPE::AUDI_FACTORY: // 奥迪工厂
pFactory = new AudiFactory();
break;
default:
break;
}
return pFactory;
}