I am writing a box program, with various extras. I understand that proper coding requires properties to be private, but I now need to add to this program getTotalEdgeLength, getSurfaceArea, and getVolume methods. Would I put these methods in the main class? I do not know a way to only use "get" functions and keep the properties private instead of making them public and using "getters" in my class. Any solutions on how to keep my properties private, but use getters for TotalEdgeLength, etc. Thanks, here is my class so far:
private class Box {
private Double length = 0.0;
private Double width = 0.0;
private Double height = 0.0;
public Box(Double boxlen, Double boxwid, Double boxhei)
{
length = boxlen;
width = boxwid;
height = boxhei;
}
public void setLength(Double boxlen)
{
length = boxlen;
}
public Double getLength()
{
return length;
}
public void setWidth(Double boxwid)
{
width = boxwid;
}
public Double getWidth()
{
return width;
}
public void setHeight(Double boxhei)
{
height = boxhei;
}
public Double getHeight()
{
return height;
}
}