Question: Purpose: To write an Object-Oriented application using abstraction, inheritance, encapsulation, and polymorphism in java to handle an inheritance structure of various shapes. Details: (Java) Implement
Purpose:To write an Object-Oriented application using abstraction, inheritance, encapsulation, and polymorphism in java to handle an inheritance structure of various shapes.
Details: (Java)
Implement the following Shape hierarchy:
| Shape / | \ Circle. Square. Triangle |
Use the following as a guide:
The Shapeclass should be abstract and contain two abstract methods:
getArea Which calculates the area of the shape and returns that value as a double.
getPerimeter Which calculates the perimeter of the shape and return that value as a double.
And one concrete method:
getName that returns the shapes name as a String.
The Circleclasss constructor should take a singleparameter of type doublerepresenting its diameter. No error checking is required.
The Squareclasss constructor should take a singleparameter of type doublerepresenting the length of its sides. No error checking is required.
The Triangleclasss constructor should take a singleparameter of type doublerepresenting the length of its sides. No error checking is required.
No setand getmethods are needed. Do not include them in the any of the classes.
Create a second class called TestShapesthat contains the mainmethod. This test class does not need to ask users for input. The class should do the following:
Create an array of size three, that uses Shapereferences. Fill the array with one of each concrete class in the hierarchy.
Iterate through the array of shapes and doing the following:
Display the shapes name.
Display the shapes area.
Display the shapes perimeter.
Note:Ensure that your program is properly formatted and it follows all Java naming conventions.
( I also need some type of pseudocode for this assignment)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
