Shape Class JAVA Implement the Shape hierarchy shown in figure below. Shape TwoDimensionalShape ThreeDimensionalShape Circle Square Sphere Cube Each TwoDimensionalShape should contain method getArea to calculate thearea of the two-dimensional shape. Each ThreeDimensionalShape should have methods getArea and getVolume tocalculate the surface area and volume, respectively, of the three- dimensional shape. Add OneDimensionalShape with sub classes , and add more shapes to classes (TwoDimensionalShape , ThreeDimensionalShape ). Create a program that uses an array of Shape references to objects of each concrete 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 OneDimensionalShape, whether each shape is a ThreeDimensionalShape. If it is a display TwoDimensionalShape or TwoDimensionalShape, its area. If it is ThreeDimensionalShape, display its area and volume.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question
Shape Class JAVA
Implement the Shapehierarchy shown in figure below.
Shape
TwoDimensionalShape
ThreeDimensionalShape
Circle
Square
Sphere
Cube
Each TwoDimensionalShape should contain method getArea to
calculate thearea of the two-dimensional shape.
• Each ThreeDimensionalShape should have methods getArea and
getVolume tocalculate the surface area and volume, respectively, of the
three- dimensional shape.
Add OneDimensionalShape with sub classes , and add more shapes
to classes (TwoDimensionalShape , ThreeDimensionalShape ).
Create a program that uses an array of Shape references to objects of
each concrete 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
OneDimensionalShape,
whether
each
shape
is
a
TwoDimensionalShape or a ThreeDimensionalShape. If it is a
TwoDimensionalShape,
it is
display
ThreeDimensionalShape, display its area and volume.
its
area.
If
a
Transcribed Image Text:Shape Class JAVA Implement the Shapehierarchy shown in figure below. Shape TwoDimensionalShape ThreeDimensionalShape Circle Square Sphere Cube Each TwoDimensionalShape should contain method getArea to calculate thearea of the two-dimensional shape. • Each ThreeDimensionalShape should have methods getArea and getVolume tocalculate the surface area and volume, respectively, of the three- dimensional shape. Add OneDimensionalShape with sub classes , and add more shapes to classes (TwoDimensionalShape , ThreeDimensionalShape ). Create a program that uses an array of Shape references to objects of each concrete 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 OneDimensionalShape, whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If it is a TwoDimensionalShape, it is display ThreeDimensionalShape, display its area and volume. its area. If a
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 9 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,