Question
In Java, Implement the Shape hierarchy in Fig. 1. 1. Shape needs to be implemented as an abstract class. 2. Each Two Dimensional Shape should
In Java,
Implement the Shape hierarchy in Fig. 1.
1. Shape needs to be implemented as an abstract class.
2. Each Two Dimensional Shape should contains method getArea() to calculate the area of the two-dimensional shape.
3. Each Three Dimensional Shape should contains method getArea() and getVolume() to calculate the surface area and volume, respectively, of the three-dimensional shape.
4. Create a program that uses an array of Shape references to objects of each concrete class in the hierarchy.
Print a text description of the object to which each array element refers.
All the shapes in the array are needed to be processed
determine whether a shape is a TwoDimensionalShape or a ThreeDimensionalShape
if it is a TwoDimensionalShape, display its area;
if it is a TwoDimensionalShape, display its area and volumn.
Thank you in advance!
Shape TwoDimensionalShape ThreeDimensionalShape Cirele Square Triangle Sphere Cube Tetrahedron Fig. 1. Shape HierarchyStep 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