From 29b40528c6b7fc5ac56acc6dc6054b5270349c73 Mon Sep 17 00:00:00 2001 From: Angeld55 Date: Thu, 19 Sep 2019 21:17:07 +0300 Subject: Add files via upload --- Polymorphism/Rectangle.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Polymorphism/Rectangle.hpp (limited to 'Polymorphism/Rectangle.hpp') diff --git a/Polymorphism/Rectangle.hpp b/Polymorphism/Rectangle.hpp new file mode 100644 index 0000000..72d1e7f --- /dev/null +++ b/Polymorphism/Rectangle.hpp @@ -0,0 +1,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)); + } +}; \ No newline at end of file -- cgit v1.3.1-23-gd82d