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!!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.