I am having some issues learning inheritance. I have stumbled across this example in my book but it has got me floundered. I am not expecting a resolution to this but maybe a little push in the right direction.

I need to write an inheritance hierarchy for classes quadrilateral, trapezoid, parallelogram, rectangle and square. Quadrilateral bieng the superclass of the heirarchy. Make the hierarchy as deep as possible. Specify the instance variables and methods for each class. The private instance variable of Quadrilateral should be the x-y coordinate pairs for the four ended points fo the Quadrilateral. I then need to write a program that instantiates objects of my classes and outputs each objects area. I am so lost right now so any lead into the right direction would be awesome. Thanks!!

11 Years
Discussion Span
Last Post by Phaelax

Make a class of Quadrilateral, which is any shape with 4 sides. It will have an X and Y for 4 different points. Any shape having 4 sides will have those variables in common. You could then make your Rectangle class which extends the Quadrilateral class. By extending the class, your Rectangle class now has access to those various parameters in Quadrilateral. I'm not very good at explaining this stuff, I just do it. But hopefully its given you an idea about how to inherit properties.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.