Question: (a) Write an abstract superclass encapsulating the concept of a 3-D shape, called GeometricShape. The superclass has two abstract methods: one returning the surface area

(a) Write an abstract superclass encapsulating the concept of a 3-D shape, called GeometricShape. The superclass has two abstract methods: one returning the surface area of a 3-D geometric shape, and another returning the volume of a 3-D geometric shape. GeometricShape class has two non-abstract methods called CompareVolume and CompareSurface. The CompareVolume method accepts two parameters representing the volumes of two geometric shapes and returns an integer value equal to 0 if the two geometric shapes volumes are equal, a 1 if the first geometric shape volume is greater than the second, and -1 if the first geometric shape volume is less than the second. Similarly, the CompareSurface method returns an integer value equal to 0, 1, or -1 if the first geometric shape is equal to, greater than or less than the second geometric shape surface area. It also has a constant field PI (). This class has two non-abstract subclasses: one encapsulating a sphere, and the other encapsulating a parallelepiped. (b) A Sphere has one additional attribute, its radius. Include a constructor that accepts a parameter for initializing its radius, and getter method to return the value of the instance variable. Include a toString method that returns a string representing the sphere radius, volume and surface area. (c) A Parallelepiped has three additional attributes, its width, length and height. Include a constructor that accepts three parameters that initialize its width, length and height fields, and getter methods to return the values of the instance variables. Include a toString method that returns a string representing a parallelepiped width, length, height, volume and surface area. (d) Write a client class, called ShapesCollection, that maintains a list of GeometricShape created by a user. The client class prompts a user for the geometric shape type and its corresponding parameters to create. The program allows the user to specify up to 10 geometric shape objects to be stored in an array. Also, it allows the user to select between displaying the geometric objects in ascending order based on their volume or surface area. Display the geometric shapes information including their geometric type, parameters, volume and surface area.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!