Polymorphism (Easy)
1. Create a program using the following information to work with the given main method.
The program has hierarchy as shown in the picture.
From the 4 types of Shape which are Circle, Sphere, Square and Cube can be
Every type of shape has a method named ConvertToString which can show the name
Every shape has an attribute named length to store data of shape length or radius.
For 2D shape has a method named getArea() to calculate the area of shape
categorized to TwoDShape and ThreeDShape
of shape type.
Area of Circle = π(radius)
Area of Square = length
2
2
For 3D shape has a method name getVolume() to calculate the volume of shape
Also, 3D shape has area calculation. Implement this formula for each 3D shape.
Volume of Sphere =
Volume of Cube = (length)
Area of Sphere = 4π(length)
Area of Cube = 6(length)
4
π(length)
3
3
3
2
2