Question: Use the following as a guide: The Shape class should be abstract and contain two abstract methods: public double getArea that returns the area. public

Use the following as a guide:

The Shape class should be abstract and contain two abstract methods:

public double getArea that returns the area.

public double getPerimeter that returns the perimeter.

and one concrete method:

public String getName that returns the shapes name.

The Circle classs constructor should take a double representing its diameter.

The Square classs constructor should take a double representing the length of its sides.

The Triangle classs constructor should take a double representing the length of its sides.

Create a test class called TestShapes that does the following:

Create an array of size three, that uses Shape references. Fill the array with one of each concrete class in the hierarchy.

Loop through the array of shapes and doing the following:

Display the shapes name.

Display the shapes area.

Display the shapes perimeter.

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!