AlexDorohoff / OOP

Лабораторные работы по ООП
0 stars 0 forks source link

Замечания по фигурам #9

Open alexey-malov opened 6 years ago

alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
    CreateShape createShape(std::cin);

    while (auto shape = createShape.ExecuteCommand())
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
std::shared_ptr<IShape> ShapeCreator::CreateRectangle(std::istream& args) const
{
    CPoint leftTop, rigthBottom;
    std::string outlineColor, fillColor, inputValue;
    try
    {
        args >> inputValue;
        leftTop.x = std::stod(inputValue);
        args >> inputValue;
        leftTop.y = std::stod(inputValue);

        inputValue.clear();

        args >> inputValue;
        rigthBottom.x = std::stod(inputValue);
        args >> inputValue;
        rigthBottom.y = std::stod(inputValue);

        args >> outlineColor;

        args >> fillColor;
    }
    catch (const std::exception& e)
    {
        std::cout << e.what() << std::endl;
        return nullptr;
    }
    return std::make_shared<CRectangle>(leftTop, rigthBottom, outlineColor, fillColor);
}
alexey-malov commented 6 years ago
    ShapeCreator inputShape(std::cin);

    while (auto shape = inputShape.ExecuteCommand())
    {
        shapes.push_back(shape);
    }
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
class ISolidShape : public CShape
{
public:
    virtual ~ISolidShape(){};
    virtual std::string GetFillColor() const = 0;

private:
    virtual void AppendProperties(std::ostream& strm) const = 0;
};
alexey-malov commented 6 years ago
    double m_density;
    std::string m_type;
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
class CRectangle final : public CSolidShape
{
private:
    CPoint m_leftTop;
    CPoint m_rightBottom;
    double m_width;
    double m_height;
};
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
1>c:\teaching\ips\2018\oop\dorohov\oop\lab4\lab4\csolidshape.h(15): warning C4250: 'CSolidShape': inherits 'CShape::CShape::GetOutlineColor' via dominance
1>c:\teaching\ips\2018\oop\dorohov\oop\lab4\lab4\cshape.h(9): note: see declaration of 'CShape::GetOutlineColor'
1>c:\teaching\ips\2018\oop\dorohov\oop\lab4\lab4\csolidshape.h(15): warning C4250: 'CSolidShape': inherits 'CShape::CShape::ToString' via dominance
1>c:\teaching\ips\2018\oop\dorohov\oop\lab4\lab4\cshape.h(10): note: see declaration of 'CShape::ToString'
1>c:\teaching\ips\2018\oop\dorohov\oop\lab4\lab4\ccircle.h(21): warning C4250: 'CCircle': inherits 'CShape::CShape::GetOutlineColor' via dominance
1>c:\teaching\ips\2018\oop\dorohov\oop\lab4\lab4\cshape.h(9): note: see declaration of 'CShape::GetOutlineColor'
1>c:\teaching\ips\2018\oop\dorohov\oop\lab4\lab4\ccircle.h(21): warning C4250: 'CCircle': inherits 'CShape::CShape::ToString' via dominance
1>c:\teaching\ips\2018\oop\dorohov\oop\lab4\lab4\cshape.h(10): note: see declaration of 'CShape::ToString'
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
class CShape : public virtual IShape
{
public:
    std::string GetOutlineColor() const override;
    std::string ToString() const override;
    void SetOutlineColor(std::string const& outlideColor);
    virtual void AppendProperties(std::ostream& strm) const = 0;

private:
    std::string m_color;
    std::string m_outlineColor;
};
alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
class CRectangle final : public CSolidShape
{
    ...
    std::string m_outlineColor;
    std::string m_fillColor;
};
alexey-malov commented 6 years ago
        auto max = std::max_element(
            arr.begin(), arr.end(),
            [](std::shared_ptr<IShape> a, std::shared_ptr<IShape> b) {
                return a->GetArea() < b->GetArea();
            });
alexey-malov commented 6 years ago