Question: Squares AIM: Suppose a Python class Point is defined in the program point.py as follows: class Point: Write a Python class Quadrilateral for representing quadrilaterals.

 Squares AIM: Suppose a Python class Point is defined in theprogram point.py as follows: class Point: Write a Python class Quadrilateral for

Squares AIM: Suppose a Python class Point is defined in the program point.py as follows: class Point: Write a Python class Quadrilateral for representing quadrilaterals. This class has four data attributes pt1, pt2, pt3, pt 4 of class Points for the four endpoints of the quadrilateral. In addition to the constructor for initializing the instance, it provides the methods getpt1 (self), getpt2 (self), getpt 3 (self), getpt 4 (self) for returning the individual endpoints of the quadrilateral, getcoorstr (self) for returning a string containing the coordinates of the endpoints of the quadrilateral, and ___str___ (self) for returning a string representation of the quadrilateral with the coordinates of its endpoints obtained by calling the method getcocrstr. Next, write a Python class Trapezoid for representing trapezoids by inheriting from the class Quadrilateral. It overrides the method str (self) for returning a string representation of the trapezoid with the coordinates of its endpoints, its height, and its area. It also adds the new methods getheight(self) for returning the height of the trapezoid, getsumoftwosides (self) for returning the sum of the length of the two parallel sides of the trapezoid, and getarea (self) for returning the area of the trapezoid, assuming the points on each parallel side to have the same y coordinates. Next, write a Python class Parallelogram for representing parallelograms by inheriting from the class Trapezoid. It overrides the method ___str__(self) for returning a string representation of the parallelogram with the coordinates of its endpoints, its width, its height, and its area. It also adds the new method getwidth (self) for returning the width of the parallelogram. Finally, write a Python class Square for representing squares by inheriting from the class Parallelogram. It overrides the method __str___ (self) for returning a string representation of the square with the coordinates of its endpoints, its side, and its area. Assume the constructors of these classes are called with valid input. Here are the sample input and output for using these classes

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!