Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions