Question: 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.

 Question 1a: Extending Geometric Shapes (2 points) Add the method areato the classes Line and Rectangle that returns the area of thegiven shapes. The area of a line is always 0 class Shape:

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.y self.x + dx, self.ydy 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) "), width"str(self.w) +", height "str(self.h) r Rectangle(-2, -3, 2, 3) 1 = Line(1, 2, 5, 6) str(r) "Rectangle at (-2, -3), width 2, str(1) "Line from (1, 2) to (5, 6)" 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!