QtDesignPatterns/abstractfactorypattern/factoryproducer.h

23 lines
424 B
C
Raw Permalink Normal View History

2024-02-06 17:21:37 +08:00
#include "abstractfactory.h"
class FactoryProducer
{
public:
FactoryProducer(){}
AbstractFactory *getFactory(string type)
{
if (type.compare("ShapeFactory") == 0)
{
return new ShapeFactory();
}
else if (type.compare("ColorFactory") == 0)
{
return new ColorFactory();
}
else
{
return nullptr;
}
}
};