Implement the shape hierarchy show in the figure below. Each twoDimensionalShape should contain method getArea to calculate the area of the two-dimensional shape. Each threeDimensionalShape should have methods getArea and getVolume to calculate the surface area and volume, respectively, of the three-dimensional shape. Create a program that uses an array of shape references to objects of each class in the hierarchy. The program should print a text description of the object to which each array element refers. Also, in the loop that processes all the shapes in the array, determine whether each shape is a twoDimensionalShape or a threeDimensionalShape. If it’s a twoDimensionalShape, display its area. If it’s a threeDimensionalShape, display its area and volume.
Hmmm... This is a tough one :(
We need the Motivation and Support! 💪
Our expert tutor in charge of answering this question
needs a cup of coffee to get pumped!
And unlock the solution to this question.