Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


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

Computer Science

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.

 

  • add a specific shape to the collection (i.e. the ArrayList): the user should be asked to enter the type of shape and the required dimensions for the specific shape. Then the area and perimeter for 2-dimensional shapes or the surface area and volume for 3-dimensional shapes will be displayed.
  • display the information of all the shapes in the collection
  • display the information of all the 2-dimentional shapes
  • display the information of all the 3-dimensional shapes
  • display the information of all of a specific shape, e.g., circles, squares, etc.

Formulae for 3d shapes:

Option 1

Low Cost Option
Download this past answer in few clicks

18.99 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE