From 55a6b0c282ff6cbf80414364d08e5a570df81048 Mon Sep 17 00:00:00 2001 From: lolabird Date: Fri, 16 Feb 2024 16:56:28 -0700 Subject: [PATCH] Add initial methods --- .../Chapter-17-18-Exercises/rectangle.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/thinkcspy/Chapter-17-18-Exercises/rectangle.py b/thinkcspy/Chapter-17-18-Exercises/rectangle.py index c426331..eb9f042 100644 --- a/thinkcspy/Chapter-17-18-Exercises/rectangle.py +++ b/thinkcspy/Chapter-17-18-Exercises/rectangle.py @@ -1,4 +1,21 @@ from points import Point -a = Point(5, 6) -print(a) \ No newline at end of file +class Rectangle: + def __init__(self, pos, width, height): + self.pos = pos + self.width = width + self.height = height + + def getWidth(self): + return self.width + + def getHeight(self): + return self.height + + def __str__(self): + return "Lower Left Coordinates: {}; Width: {}; Height: {}".format(self.pos, self.width, self.height) + + +r = Rectangle(Point(4, 5), 6, 5) +print(r) + \ No newline at end of file