Fill This Form To Receive Instant Help
Homework answers / question archive / Class Hierarchy (THINK: which classes should be concrete and which should be abstract/interface?) 1
Class Hierarchy (THINK: which classes should be concrete and which should be abstract/interface?)
1. Shape (this is the top level class in your program)
1.1 TwoDShape
o Circle
o Square
o Rectangle
o Triangle (only right-angle triangles if you’d prefer but you must specify in the
program)
o Parallelogram
1.2 ThreeDShape
o Sphere
o Cylinder
o Cone
o Cube
o Prism
o SquarePyramid
Requirements
Each TwoDShape should contain methods getArea() and getPerimeter() to retrieve the area and the perimeter of a two-dimensional shape. Each ThreeDShape should have methods getArea() and getVolume() to retrieve the surface area and the volume of a three-dimensional shape. (See the class hierarchy diagram above and the formulae for the 3-dimensional shapes below)
Note: You should consider having a main() in each class and to test the methods in each class independently to make sure the class works as intended (just like Assignment 2). Then you should make the main() in the driver class to driver the program.
Your program will use a single ArrayList of Shape references to objects of each concrete class in the hierarchy. Make sure to include appropriate constructor(s) and dimensions specific to each class. The program should continually allow the users to do the following until s/he wants to quit.
Formulae for 3d shapes: