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. 12/Example_polymorphism/Rectangle.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Sem. 12/Example_polymorphism/Rectangle.cpp') diff --git a/Sem. 12/Example_polymorphism/Rectangle.cpp b/Sem. 12/Example_polymorphism/Rectangle.cpp index 3fa1026..3797b41 100644 --- a/Sem. 12/Example_polymorphism/Rectangle.cpp +++ b/Sem. 12/Example_polymorphism/Rectangle.cpp @@ -23,4 +23,11 @@ double Rectangle::getPer() const Shape::point p3 = getPointAtIndex(3); return 2*(p0.getDist(p1) + p0.getDist(p3)); -} \ No newline at end of file +} + +bool Rectangle::isPointIn(int x, int y) const +{ + Shape::point p(x, y); + return p.x >= getPointAtIndex(0).x && p.y >= getPointAtIndex(1).x && + p.y <= getPointAtIndex(0).y && p.y >= getPointAtIndex(2).y; +} -- cgit v1.3.1-23-gd82d