#include #include class Figure { public: virtual std::string Name() = 0; virtual double Perimeter() = 0; virtual double Area() = 0; }; class Triangle : public Figure { public: Triangle(const int& a, const int& b, const int& c) { one = a; two = b; three = c; } string Name() { return "TRIANGLE"; } double Perimeter() { int x = one + two + three; return x; } double Area() { double P = (one + two + three); P = P / 2.0; P = sqrt(P * (P - one) * (P - two) * (P - three)); return P; } private: int one, two, three; }; class Rect : public Figure { public: Rect(const int& a, const int& b) { one = a; two = b; } string Name() { return "RECT"; } double Perimeter() { int x = (one + two) * 2; return x; } double Area() { int x = one * two; return x; } private: int one, two; }; class Circle : public Figure { public: explicit Circle(const int& a) { r = a; } string Name() { return "CIRCLE"; } double Perimeter() { int x = 2 * 3.14 * r return x; } double Area() { int x = 3.14 * r * r; return x; } private: int r; }; std::shared_ptr
CreateFigure(std::istringstream& is) { std::string figure; is >> figure; if (figure == "RECT") { int one, two; is >> one >> std::ws >> two; return std::make_shared(one, two); } else if (figure == "TRIANGLE") { int one, two, three; is >> one >> std::ws >> two >> std::ws >> three; return std::make_shared(one, two, three); } else { int one; is >> one; return std::make_shared(one); } }