以下文字与答案无关
提示:有些试题内容 显示不完整,文字错误 或者 答案显示错误等问题,这是由于我们在扫描录入过程中 机器识别错误导致,人工逐条矫正总有遗漏,所以恳请 广大网友理解。
Before:
public class Rectangle { private int length, width; public Rectangle(int length, int width) { this.length = length; this.width = width; } }
After:
}
}
public class Main {
public (1分) main(String] args) {
Scanner input = new Scanner(System.in);
int w = input.nextInt();
int h = input.nextInt();
int l = input.nextInt();
Box box1 = (1分)
System.out.println(box1.toString());
box1.setWidth(5);
box1.setFull((1分));
System.out.println(box1.toString());
}
}
">15.设计并实现Box类,它包含盒子的高度、宽带和深度的实例数据:还包含布尔变量full这个实例数据,变量full表示盒子是否满了。所有数据都定义为私有。定义Box构造函数接收并初始化盒子的高度、宽带和深度。每次新创建的Box都为空,构造函数将full初始化为假。该类所有实例都有getter和setter方法;该类还包含了一个计算盒子体积的方法。
(1分)
class (1分) {
private boolean (1分);
private int width;
private int height;
private int lenght;
public Box((1分)) {
full = false;
this.width = width;
this.height = height;
this.lenght = lenght;
}
public (1分) isFull() {
return full;
}
public void setFull(boolean full) {
this.full = full;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int h) {
this.height = height;
}
public int getLenght() {
return lenght;
}
public void setLenght(int lenght) {
this.lenght = lenght;
}
public int getVolumn() {
(1分)
}
@Override
public String (1分) {
return "Box is " + (full ? "full" : "empty") + ", The Volumn is " + getVolumn();
}
}
public class Main {
public (1分) main(String] args) {
Scanner input = new Scanner(System.in);
int w = input.nextInt();
int h = input.nextInt();
int l = input.nextInt();
Box box1 = (1分)
System.out.println(box1.toString());
box1.setWidth(5);
box1.setFull((1分));
System.out.println(box1.toString());
}
}
End Off Screen |
Ramp Up |
Ramp Down |
Start Off Screen |
End Off Screen |
Ramp Up |
Ramp Down |