EvgeniyGlazirin / oop

0 stars 0 forks source link

Замечания по Shapes #8

Open alexey-malov opened 6 years ago

alexey-malov commented 6 years ago
class IShape
{
public:
    IShape();
    virtual double GetArea() const = 0;
    virtual double GetPerimeter() const = 0;
    virtual std::string ToString() const = 0;
    virtual std::string GetOutlineColor() const = 0;
//  virtual void SetOutlineColor(const std::string &color) = 0;
};
class ISolidShape : public IShape
{
public:
    virtual ~ISolidShape() = default;
    virtual std::string GetFillColor() const = 0;
};
alexey-malov commented 6 years ago

Остался ISolidShape.cpp

alexey-malov commented 6 years ago
double CTriangle::GetLength(CPoint const & point1, CPoint const & point2) const
{
    return sqrt(pow((point1.GetX() - point2.GetX()), 2)
        + pow((point1.GetY() - point2.GetY()), 2));
}
alexey-malov commented 6 years ago
class CShapeCreator
{
public:
    CShapeCreator(std::istream &input);
    ~CShapeCreator();
    std::shared_ptr<IShape> HandleCommand() const;

private:
    std::map<std::string, std::function<std::shared_ptr<IShape>(std::istringstream &strm)>> m_actionMap;
    std::shared_ptr<IShape> CreateLine(std::istringstream & strm) const;
    std::shared_ptr<IShape> CreateTriangle(std::istringstream & strm) const;
    std::shared_ptr<IShape> CreateRectangle(std::istringstream & strm) const;
    std::shared_ptr<IShape> CreateCircle(std::istringstream & strm) const;
    std::istream& m_input;
};
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago