24 lines
508 B
C++
24 lines
508 B
C++
#include "interface.h"
|
|
#include <map>
|
|
|
|
class ShapeFactory
|
|
{
|
|
public:
|
|
std::map<string, Shape*> map;
|
|
auto getCircle(string color)->Shape*
|
|
{
|
|
auto iter = map.find(color);
|
|
if (iter != map.end())
|
|
{
|
|
return iter->second;
|
|
}
|
|
else
|
|
{
|
|
Shape *circle = new Circle(color);
|
|
map.insert(std::make_pair(color, circle));
|
|
cout << "Creating circle of color : " + color << endl;
|
|
return circle;
|
|
}
|
|
}
|
|
};
|