Website Summary Files Commits Branches @commit @diff @stats
path: root / Polymorphism / Figures / Rectangle.hpp
blob: 702188674409a7840d5f2850f769c03bc45f3b5f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "Figure.hpp"
class Rectangle : public Figure
{
public:
	Rectangle(int x1, int y1, int x2, int y2) : Figure(4)
	{
		setPoint(0, x1, y1);
		setPoint(1, x2, y1);
		setPoint(2, x2, y2);
		setPoint(3, x1, y2);
	}
	double getPer()
	{
		return 2 * (getPoint(0).getDistTo(getPoint(1)) + getPoint(0).getDistTo(getPoint(3)));
	}
	double getArea()
	{
		return getPoint(0).getDistTo(getPoint(1))* getPoint(1).getDistTo(getPoint(2));   
	}
};