Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the superclass of the hierarchy. Specify the instance variables and

Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the superclass of the hierarchy. 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. Write a program that instantiates objects of your classes and outputs each objects area (except Quadrilateral). Hint: Create and use a Point class to represent the corners of the shapes.(use java and please it's not allowed to se any math.abs, math.max etc)
Sample output:
Coordinates of Quadrilateral are: (1.1,1.2),(6.6,2.8),(6.2,9.9),(2.2,7.4)
Coordinates of Trapezoid are: (0.0,0.0),(10.0,0.0),(8.0,5.0),(3.3,5.0)
Height is : 5.0
Area is : 36.75
Coordinates of Parallelogram are: (5.0,5.0),(11.0,5.0),(12.0,12.0),(6.0,6.0)
Width is : 6.0
Height is : 15.0
Area is : 90.0
Coordinates of Rectangle are: (17.0,14.0),(30.0,14.0),(30.0,28.0),(17.0,28.0)
Width is : 13.0
Height is : 14.0
Area is 182.0
Coordinates of Square are: (4.0,4.0),(8.0,8.0),(8.0,4.0),(4.0,4.0)
Side is : 4.0
Area is : 16.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago