Question
(In java) Implement the following hierarchy of objects. (In Java) The area and the perimeter are values that will be available for each of the
(In java) Implement the following hierarchy of objects. (In Java)
The area and the perimeter are values that will be available for each of the subclasses. In order to determine these two parameters, You will have to also create as many local attributes as needed to make it happen. For example, in order to calculate the area of a circle, you will need at least ( but also at most ) the radius as the local attribute in the circle class. In order to calculate the area of a square, you will need at least ( and at most ) the side as the local attribute in the square class, of the square etc.
Once you design your subclasses you will need to implement the getters and setters. Then, using your sample values assign the values, and outcomes the area from the child object. Implement the calculations for the perimeter as well in a similar manner.
Test the objects by assigning the following sample values. When area and/or perimeter is being printed, restrict the printed output to 2 digits after the decimal point. (In java)
shape area perimeter ellipso Square circle + rectangle triangle parallogram rhombus Squares Square 1 _side=7.2 Square2 _side=8.4 Rectangles Rectangle1 _length=4.8, _width=8.4 Rectangle2 _length=12.2, _width=14.4 Rhombuses Rhombus1 _diagonal1=12.2, _diagonal2=8.4 Rhombus2 _diagonal1=10.6, _diagonal2=16.8 Parallelograms Parallelogram _base=8.2, _side=6.2, _height=4.6 Parallelogram _base=10.6, _side=8.6, _height=7.6 Circles Circle1 _radius=12.4 Circle2 _radius=16.6 Triangles Triangle1 _side 1=6.4, _side2=8.4, _side3=12.8 Triangle2 _side 1=12.2, _side2=14.6, _side3=16.6 Ellipses Ellipse1 _axis 1=8.6, _axis2=12.2 Ellipse2 _axis 1=14.8, _axis2=16.4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started