Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON 3 CODE REQUIRED Add the method area to the classes Line and Rectangle that returns the area of the given shapes. The area of
PYTHON 3 CODE REQUIRED
Add the method area to the classes Line and Rectangle that returns the area of the given shapes. The area of a line is always 0 ]: class Shape: def setOrigin(self, x, y): self.x, self.y = x, y def move (self, dx, dy): ""Move by dx and dy" self.x, self.y = self.x + dx, self.y + dy class Line (Shape): def init (self, x, Y, u, v) ""Line with start point (x, y) and end point (u, v)" Shape.setOrigin(self, x, y) self.u, self . v = u, v def move (self, dx, dy) Shape.move (self, dx, dy) self.u, self.v = self.u + dx, self.v + dy def area(self): pass # Replace this line with your body def-str (self): return "Line from ("str (self.x) + ", " str(self.y) ") to ( +str (self.u) str(self.v) +)" class Rectangle (Shape): def -init-(self, x, y, w, h): "Rectangle at (x, y) with width w and height h"" Shape.setOrigin(self, x, y) self.w, self . h = w, h def area(self): pass # Replace this line with your body def-str (self): return "Rectangle at str(self.x)+ ",str(self.y) ", widthstr(self.w) ,height "str (self.h) j: 2, 3) r= Rectangle(-2, -3, 1 = Line ( 1, str(r)"Rectangle at (-2, -3), width 2, height 3' j: 2, 5, 6) ]: str (1) "Line from (1, 2) to (5, 6)" ]: 1 . area ( ) -0 : r.area() == 6Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started