软件开发实验报告~~帮忙做一下~感激不尽
发布网友
发布时间:2022-04-30 17:50
我来回答
共3个回答
热心网友
时间:2022-06-28 16:46
package test;
public class Box {
long hight;
long weight;
long length;
public Box() {
}
public Box(long hight, long weight, long length) {
this.hight = hight;
this.weight = weight;
this.length = length;
}
public void setDemo(long hight, long weight, long length) {
this.hight = hight;
this.weight = weight;
this.length = length;
}
public long getVolume(){
return hight*weight*length;
}
public static void main(String[] args) {
Box a = new Box();
a.setDemo(1,2,3);
System.out.println(a.getVolume());
Box b = new Box(1,2,3);
System.out.println(b.getVolume());
}
}
class SubBox extends Box{
public SubBox(long hight, long weight, long length) {
super(hight,weight,length);
}
public SubBox(){
}
public long getArea(){
return (hight*weight*2 + weight*length*2 + hight*length*2);
}
public static void main(String[] args) {
SubBox a = new SubBox();
a.setDemo(1,2,3);
System.out.println(a.getArea());
SubBox b = new SubBox(1,2,3);
System.out.println(b.getArea());
}
}
热心网友
时间:2022-06-28 16:47
哥你华理的?
热心网友
时间:2022-06-28 16:47
必须华理的。。。