2018/12/11
public class Box {
private int length = 1;
private int width = 1;
private int height = 1;
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public Box(int length, int width, int height) {
this.length = length;
this.width = width;
this.height = height;
}
public void show(){
int v = length*width*height;
System.out.println("长为: "+length+" 宽为: "+width+" 高为: "+height+" 体积为: "+v);
}
}
Box x = new Box(10, 20, 30);
x.show();