Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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: 

Shape: Dimension: Two-Dimensional Area: Shape: Dimension: Area: Circle == 103.87 Square Two-Dimensional 6.25 

 package Program2; import java.awt.*; // // Developer: // // Program #f: // // File Name: // // Course: // // public class Program2 { //**** 11 // Method: 17 main // Description: The main method of the program 17 // shapes[0] = new Circle(radius); shapes [1] = new Square (length); shapes [2] = new Triangle (base, height); } // End of test class Program2 package Program2; // Developer:: 11 // Program #: 11 // File Name: // // 

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... 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

Accounting Information Systems

Authors: George H. Bodnar, William S. Hopwood

11th Edition

0132871939, 978-0132871938

More Books

Students also viewed these Programming questions

Question

What is a process and process table?

Answered: 1 week ago

Question

What is Industrial Economics and Theory of Firm?

Answered: 1 week ago

Question

What is the meaning and definition of E-Business?

Answered: 1 week ago

Question

Explain son father grandfather file retention.

Answered: 1 week ago

Question

For each, show how or explain why not. If Can C = 0? Can C

Answered: 1 week ago

Question

For each, show how or explain why not. If Can Can

Answered: 1 week ago