Java Programming I am using intellij to write my code 1. Implement the shape hierarchy shown above, in which Shape, TwoDeimentionalShape and ThreeDimentionalShape should be abstract classes. 2. Include abstract method getArea in the TwoDimensionalShape class. Also, include abstract methods getArea and getVolume in the ThreeDimensionalShape class. 3. Each subclass of TwoDimensionalShape should contain method getArea to calculate the area of the twodimensional shape. 4. Each subclass of ThreeDimensionalShape should have getArea and getVolume to calculate the surface area and volume. 5. Override the toString method in each concrete class (third level), to include basic information about the object, e.g., “Sphere object, radius = 4” • Create a test program that uses an array of Shape references to objects of each concrete class in the hierarchy. For example, Shape[] shapes = new Shapes [5]; Shape[0] = new Circle(2); • Create a loop that process all the shapes in the array, print basic information for each object. Also, determine whether each shape is TwoDimensionalShape or ThreeDimensionalShape: • If it is TwoDimensionalShape, display its area. • If it is ThreeDimensionalShape, display its area and volume
Java Programming
I am using intellij to write my code
1. Implement the shape hierarchy shown above, in which
Shape, TwoDeimentionalShape and
ThreeDimentionalShape should be abstract classes.
2. Include abstract method getArea in the
TwoDimensionalShape class. Also, include abstract
methods getArea and getVolume in the
ThreeDimensionalShape class.
3. Each subclass of TwoDimensionalShape should contain
method getArea to calculate the area of the twodimensional shape.
4. Each subclass of ThreeDimensionalShape should have
getArea and getVolume to calculate the surface area and
volume.
5. Override the toString method in each concrete class (third
level), to include basic information about the object, e.g.,
“Sphere object, radius = 4”
• Create a test program that uses an array of Shape references
to objects of each concrete class in the hierarchy. For
example,
Shape[] shapes = new Shapes [5];
Shape[0] = new Circle(2);
• Create a loop that process all the shapes in the array, print
basic information for each object. Also, determine whether
each shape is TwoDimensionalShape or
ThreeDimensionalShape:
• If it is TwoDimensionalShape, display its area.
• If it is ThreeDimensionalShape, display its area and volume
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 10 images