2018-07-22 14:50:54 +08:00
|
|
|
//
|
|
|
|
// Created by xiemenghui on 2018/7/20.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef DESIGNPATTERN_CONCRETE_FACTORY_H
|
|
|
|
#define DESIGNPATTERN_CONCRETE_FACTORY_H
|
|
|
|
|
|
|
|
#include "Factory.h"
|
|
|
|
#include "concrete_product.h"
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Benz factory
|
2018-07-22 14:50:54 +08:00
|
|
|
class BenzFactory : public Factory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ICar* CreateCar()
|
|
|
|
{
|
|
|
|
return new BenzCar();
|
|
|
|
}
|
|
|
|
IBike* CreateBike()
|
|
|
|
{
|
|
|
|
return new BenzBike();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// BMW factory
|
2018-07-22 14:50:54 +08:00
|
|
|
class BmwFactory : public Factory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ICar* CreateCar() {
|
|
|
|
return new BmwCar();
|
|
|
|
}
|
|
|
|
|
|
|
|
IBike* CreateBike() {
|
|
|
|
return new BmwBike();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Audi factory
|
2018-07-22 14:50:54 +08:00
|
|
|
class AudiFactory : public Factory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ICar* CreateCar() {
|
|
|
|
return new AudiCar();
|
|
|
|
}
|
|
|
|
|
|
|
|
IBike* CreateBike() {
|
|
|
|
return new AudiBike();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //DESIGNPATTERN_CONCRETE_FACTORY_H
|