Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java, Implement the Shape hierarchy in Fig. 1. 1. Shape needs to be implemented as an abstract class. 2. Each Two Dimensional Shape should

In Java,

image text in transcribed

Implement the Shape hierarchy in Fig. 1.

1. Shape needs to be implemented as an abstract class.

2. Each Two Dimensional Shape should contains method getArea() to calculate the area of the two-dimensional shape.

3. Each Three Dimensional Shape should contains method getArea() and getVolume() to calculate the surface area and volume, respectively, of the three-dimensional shape.

4. Create a program that uses an array of Shape references to objects of each concrete class in the hierarchy.

Print a text description of the object to which each array element refers.

All the shapes in the array are needed to be processed

determine whether a shape is a TwoDimensionalShape or a ThreeDimensionalShape

if it is a TwoDimensionalShape, display its area;

if it is a TwoDimensionalShape, display its area and volumn.

Thank you in advance!

Shape TwoDimensionalShape ThreeDimensionalShape Cirele Square Triangle Sphere Cube Tetrahedron Fig. 1. Shape Hierarchy

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

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

Discuss the structure and purpose of the health-illness continuum

Answered: 1 week ago