Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogr

ID: 3545596 • Letter: W

Question

Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the base class of the hierarchy. Create and use a Point class to represent the points in each shape. Make the hierarchy as deep (i.e., as many levels) as possible. Specify the instance variables, properties, and methods for each class. The private instance variables of Quadrilateral should be the x-y coordinate pairs for the four endpoints of the Quadrilateral. Write a program that instantiates objects of your classes and outputs each object

Explanation / Answer

Hi there

Although my previous post works, I wasn't completely happy with it because, whilst Rectangle and Square inherit from Parallelogram, they don't actually add or modify anything which ideally they should do in an inheritance hierarchy.

Here's an improved version which adds constructor overloads to the Rectangle and Square classes to distinguish them from Parallelogram. Notice that Square now inherits from Rectangle rather than directly from Parallelogram. The results are the same as before:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote