Question: python question Question 1a: Extending Geometric Shapes (2 points) Add the method area to the classes Line and Rectangle that returns the area of the

python question

python question Question 1a: Extending Geometric Shapes (2 points) Add the methodarea to the classes Line and Rectangle that returns the area ofthe given shapes. The area of a line is always 0 .

Question 1a: Extending Geometric Shapes (2 points) 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.yself.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 selE): return "Line from ( str (self.x) "," ") to ("str (self.u+,"+str (self.v) + ")" str (self.y) + 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) + ", width "str (self.w)" height "str(self.h) rRectangle (-2, -3, 2, 3) 1 -Line(, 2, 5, 6) str (r)"Rectangle at (-2,-3), width 2, height 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!