Question
Use the Program2.java and the Shape.java files attached to implement the Shape hierarchy shown in the diagram below. Each TwoDimensionalShape should contain method getArea to
Use the Program2.java and the Shape.java files attached to implement the Shape hierarchy shown in the diagram 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. Write a program that uses an array of Shape references to objects of each concrete class in the hierarchy. Write a main test class (provided as Program2.java) that uses an array of Shape references to objects of each concrete class in the hierarchy. This class should print a text description of the object. The class 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 TwoDimension
This hierarchy begins with the superclass, Shape, which is extended by two subclasses, TwoDimensionalShape and ThreeDimensionalShape. In geometry, Shapes are either two dimensional or three dimensional. The third level of this hierarchy contains specific types of two dimensional shapes and three dimensional shapes. You can follow the arrows from the bottom of the diagram to the topmost superclass in this class hierarchy to identify several is-a relationships. For instance, a Triangle is a TwoDimensionalShape and is a Shape, while a Sphere is a ThreeDimensionalShape and is a Shape.
The outcome should be:
Can you provide the two classes TwoDimentional and ThreDimentional to provide the sample outcome.
The two codes provided cannot be altered!
Shape: Dimension: Two-Dimensional Area: Shape: Dimension: Area: Circle == 103.87 Square Two-Dimensional 6.25 ==
Step by Step Solution
3.44 Rating (163 Votes )
There are 3 Steps involved in it
Step: 1
Approach to solving the question Follow these steps to develop the Shape hierarchy as defined and create a main test class in Java Detailed explanatio...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