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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started