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
Step: 1
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