Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 13 / ShapeCollection / Circle.cpp
blob: 67762d8e2257c7bdb1cedba5c0952b3bf3a381be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}