27 lines
481 B
C
27 lines
481 B
C
|
#include "interface.h"
|
||
|
|
||
|
class ShapeFactory
|
||
|
{
|
||
|
public:
|
||
|
ShapeFactory(){}
|
||
|
Shape* getShape(string type)
|
||
|
{
|
||
|
if (type.compare("Circle") == 0)
|
||
|
{
|
||
|
return new Circle();
|
||
|
}
|
||
|
else if (type.compare("Square") == 0)
|
||
|
{
|
||
|
return new Square();
|
||
|
}
|
||
|
else if (type.compare("Rectangle") == 0)
|
||
|
{
|
||
|
return new Rectangle();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return nullptr;
|
||
|
}
|
||
|
}
|
||
|
};
|