Question: Write an inheritance hierarchy for classes Quadrilateral, Parallelogram, Rectangle, and Square. JAVA CODE Use Quadrilateral as the superclass of the hierarchy. Create and use a

Write an inheritance hierarchy for classes Quadrilateral, Parallelogram, Rectangle, and Square. JAVA CODE

Use Quadrilateral as the superclass of the hierarchy. Create and use a Point class to represent the points in each shape. Make the hierarchy as deep as possible, i.e. more than two levels. Specify the instance variables 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. A program that instantiates objects of your classes and outputs each object's area (except Quadrilateral) has been provided.

the code provided

public class QuadrilateralTest { public static void main(String[] args) { // NOTE: All coordinates are assumed to form the proper shapes // A quadrilateral is a four-sided polygon Quadrilateral quadrilateral = new Quadrilateral(1.1, 1.2, 6.6, 2.8, 6.2, 9.9, 2.2, 7.4);

// A parallelogram is a quadrilateral with opposite sides parallel Parallelogram parallelogram = new Parallelogram(5.0, 5.0, 11.0, 5.0, 12.0, 20.0, 6.0, 20.0);

// A rectangle is an equiangular parallelogram Rectangle rectangle = new Rectangle(17.0, 14.0, 30.0, 14.0, 30.0, 28.0, 17.0, 28.0);

// A square is an equiangular and equilateral parallelogram Square square = new Square(4.0, 0.0, 8.0, 0.0, 8.0, 4.0, 4.0, 4.0);

System.out.printf( "%s %s %s %s ", quadrilateral, parallelogram, rectangle, square); } }

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!