I am working on a homework asisgnment from school and need some help. I am stuck on coding to set a private field to my Box class with three constructors.. It's kind of confusing when dealing with more than one constructor. The following is the code for the box class progam. Can any one assist me. Please follow the comments Thanks! //two arg constructor that sets length and width
public Box(int l, int w) {// write code to set the private field
}
/** The Box class with three constructors */
public class Box{
// three class variables
private int length;
private int width;
private int height;
//one arg constructor should take one parameter and set the length equal to that. Width and height should be set to zero.
public Box( int l) {
length = l;
width =0;
height=0;
}
//two arg constructor that sets length and width
public Box(int l, int w) {
// write code to set the private field
}
//three arg constructor that sets lenght, width and height
public Box(int l, int w, int h) {
// write code to set the private fields
}
// get and set methods for all the private data ie, length, width and height. I have written one method. You need to write for all three
public int getLength() {
return length;
}
public void setLength(int l){
length=l;
}
// Write get and set methods for width
public int getWidth()
{
return width;
}
public void setWidth(int w) {
width = 0;
}
// Write get and set methods for height
public int getHeight()
{
return height;
}
public void setHeight(int h) {
height = 0;
}
}