The first thing I notice is here,
public Square(height, width)
Should be
public Square(int height, int width)
The next thing I notice is
public int computeSurfaceArea()
{
// int surfaceArea = square_height * square_width;
// surfaceArea = (getheight() * getwidth());
return getheight() * getwidth();
}
Finally, I suggest you follow standard Java naming practices; getHeight()
and getWidth()
, and then getHeight()
, getWidth()
and getDepth()
in Cube
. Also it might be better to call it getSurfaceArea()
. Consistency is good (and remember the maintenance programmer).
Note this applies also to your Cube
constructor, for a quick fix –
public Cube(int height, int width, int depth) {
super(height, width); // cube_height, cube_width are defaulting to 0.
cube_depth = depth;
cube_height = height; // <-- you called it cube_height, not just height.
cube_width = width;
}
4
solved How should I fix this [closed]