I’m not asking for all the answers just if someone can help guide me in the right direction here since I have no idea where to even start on this thing.
I’m taking an intro to Java class and have this final HW assignment.
Here is some of the question:
You have to create a program that can compute the Surface Area and Volumes of various containers that are all “Right Prisms”. This means that the ends of the container are identical and the sides are perpendicular to the ends.
Each of your containers has different shapes: Circular, Rectangular, Triangular, and Regular Polygon. All of these containers are derived from a common abstract Container class.
You will then create a class called ContainerCollection which will contain an array of all of the possible Container classes. This class will provide methods to compute the totalVolume and the totalSurfaceArea of all Containers in the ContainerCollection.
Link to Gist:
https://gist.github.com/3b9fb22e72b2a3d86e1b
Text for those who can’t get gist:
abstract class Container {
double height;
Container(double height)
{
this.height = height;
}
abstract double getTopArea();
abstract double getTopPerimeter();
double getVolume()
{
return height * getTopArea();
}
double getSurfaceArea()
{
return 2*getTopArea() + height * getTopPerimeter();
}
}
class CircularContainer extends Container
{
// add appropriate data definitions
CircularContainer(double height, double radius)
{
// Fill in details
}
// implement required abstract methods
}
class RectangularContainer extends Container
{
// add appropriate data definitions
RectangularContainer(double height, double width, double length)
{
// Fill in details
}
// implement required abstract methods
}
Use an ide like eclipse for coding in java, that makes life a lot easier.
I see the skeleton code of your assignment is already present. You just need to over-ride these 4 methods in each of the child classes that extend the
Containerclassand then return the proper values that can be calculated using the specific formula’s for each shape.
Example
You should also try to enhance this code by adding proper access modifiers to the methods and variables.