Open alexey-malov opened 6 years ago
Остался ISolidShape.cpp
double CTriangle::GetLength(CPoint const & point1, CPoint const & point2) const
{
return sqrt(pow((point1.GetX() - point2.GetX()), 2)
+ pow((point1.GetY() - point2.GetY()), 2));
}
[x] Сделать свободной функцией. Можно разместить в тех же файлах, что и CPoint
[x] Использовать эту функцию как для нахождения длины LineSegment, так и периметра треугольника.
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;
};
[ ] Если это создатель, то он должен иметь методы для создания. Возможно, стоит передавать ему в метод создания фигуры поток или строку, а из конструктора выпилить
[ ] Методы создания фигур не используют состояние объекта. Их можно сделать статическими или свободными функциями в безымянном пространстве имён.
[x] C.35: A base class destructor should be either public and virtual, or protected and nonvirtual. Разобраться и уметь объяснить
[x] Убрать конструктор. У класса нет данных, значит и инициализировать нечего. Нет у него и базового класса без конструктора по умолчанию, значит и инициализировать особы образом не надо. Компилятор сам всё сделает. Это касается и других интерфейсов