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.
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.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 19RQ
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 8 steps with 9 images
Knowledge Booster
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.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,