Question: This is done by Java. Remember to ensure proper javadoc comments. This is an open-ended lab that will let you demonstrate what you understand about
This is done by Java.
-
Remember to ensure proper javadoc comments.
-
This is an open-ended lab that will let you demonstrate what you understand about inheritance. You will examine a famous OOP problem how to organize the rectangle and the square. Are they related? Which one is the superclass? Which one is the subclass? Or are they independent siblings that share a common parent?
-
You must implement an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle, and Square. Use Quadrilateral as the superclass of the hierarchy.
-
Implement a Point class to represent the points in each shape.
-
Make the hierarchy as deep, i.e., as many levels, as necessary. Be thoughtful about the instance variables that need to go in each class. To get you started, we recommend that the private instance variables inside Quadrilateral be the x-y coordinate pairs of the four endpoints.
-
Include a method called area that calculates the area of each shape.
-
Write a Driver that instantiates one object from each of the classes and outputs each objects area. Your Driver may only use variables of type Quadrilateral (hint: use polymorphism!)
Requirement
Generating code that compiles and executes without crashing or looping infinitely
Meeting the functional requirements in this lab, i.e., does the code do what it is supposed to do
Writing code that is self-documenting, with correct and complete Javadocs, using short and atomic methods correctly encapsulated in classes that are well defined.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
