Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions