Question: I am creating a Java program to implement a Shape hierarchy. Each TwoDimensionalShape contains method getArea to calculate the area of the two-dimensional shape. Each

I am creating a Java program to implement a Shape hierarchy. Each TwoDimensionalShape contains method getArea to calculate the area of the two-dimensional shape. Each ThreeDimensionalShape will have methods getArea and getVolume to calculate the surface area and volume, respectively, of the three-dimensional shape, respectively. The program wil use an array of Shape reference to objects of each concrete class in the hierarchy. The program should print the object to which each array element refers. Also, in the loop that processes all the shapes in the array, will determine whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If a shape is a TwoDimensionalShape, it will display its area. If a shape is a ThreeDimensionalShape, it will display its area and volume. My question is my TwoDimensionalShape will be a Rectangle and my ThreeDimesionalShape will be a Rectangular Prism, what formula for Java will I use to calculate Area for my Rectangle public Rectangle( int x, int y, int side ) and what Java formula will I use to calculate Area and Volume for my Rectanglular Prism using: public RectangularPrism( int x, int y, int side )??

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!