From 110481bee48bdb18f3d635cbc507aac1acc7c694 Mon Sep 17 00:00:00 2001 From: angeld55 Date: Tue, 24 May 2022 20:10:50 +0300 Subject: added shapes collection --- Sem. 13/ShapeCollection/Circle.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Sem. 13/ShapeCollection/Circle.cpp (limited to 'Sem. 13/ShapeCollection/Circle.cpp') diff --git a/Sem. 13/ShapeCollection/Circle.cpp b/Sem. 13/ShapeCollection/Circle.cpp new file mode 100644 index 0000000..67762d8 --- /dev/null +++ b/Sem. 13/ShapeCollection/Circle.cpp @@ -0,0 +1,26 @@ +#include "Circle.h" + +const double PI = 3.1415; +Circle::Circle(int x, int y, double radius) : Shape(1), radius(radius) +{ + setPoint(0, x, y); +} + +double Circle::getArea() const +{ + return PI * radius * radius; +} +double Circle::getPer() const +{ + return 2 * PI * radius; +} +bool Circle::isPointIn(int x, int y) const +{ + Shape::point p(x, y); + return p.getDist(getPointAtIndex(0)) <= radius; +} +Shape* Circle::clone() const +{ + Shape* copy = new Circle(*this); + return copy; +} \ No newline at end of file -- cgit v1.3.1-23-gd82d