mirror of
https://github.com/huihut/interview.git
synced 2026-03-13 10:02:55 +08:00
添加设计模式及例子,包括:单例、抽象工厂、适配器、桥接、观察者模式
This commit is contained in:
72
DesignPattern/AbstractFactoryPattern/concrete_product.h
Normal file
72
DesignPattern/AbstractFactoryPattern/concrete_product.h
Normal file
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// Created by xiemenghui on 2018/7/20.
|
||||
//
|
||||
|
||||
#ifndef DESIGNPATTERN_CONCRETE_PRODUCT_H
|
||||
#define DESIGNPATTERN_CONCRETE_PRODUCT_H
|
||||
|
||||
#include "product.h"
|
||||
|
||||
/********** 汽车 **********/
|
||||
// 奔驰
|
||||
class BenzCar : public ICar
|
||||
{
|
||||
public:
|
||||
string Name()
|
||||
{
|
||||
return "Benz Car";
|
||||
}
|
||||
};
|
||||
|
||||
// 宝马
|
||||
class BmwCar : public ICar
|
||||
{
|
||||
public:
|
||||
string Name()
|
||||
{
|
||||
return "Bmw Car";
|
||||
}
|
||||
};
|
||||
|
||||
// 奥迪
|
||||
class AudiCar : public ICar
|
||||
{
|
||||
public:
|
||||
string Name()
|
||||
{
|
||||
return "Audi Car";
|
||||
}
|
||||
};
|
||||
|
||||
/********** 自行车 **********/
|
||||
// 奔驰
|
||||
class BenzBike : public IBike
|
||||
{
|
||||
public:
|
||||
string Name()
|
||||
{
|
||||
return "Benz Bike";
|
||||
}
|
||||
};
|
||||
|
||||
// 宝马
|
||||
class BmwBike : public IBike
|
||||
{
|
||||
public:
|
||||
string Name()
|
||||
{
|
||||
return "Bmw Bike";
|
||||
}
|
||||
};
|
||||
|
||||
// 奥迪
|
||||
class AudiBike : public IBike
|
||||
{
|
||||
public:
|
||||
string Name()
|
||||
{
|
||||
return "Audi Bike";
|
||||
}
|
||||
};
|
||||
|
||||
#endif //DESIGNPATTERN_CONCRETE_PRODUCT_H
|
||||
Reference in New Issue
Block a user