写长方体类,并测试输出长方体的表面积和体积( •︠ˍ•︡ )求解答
仔细想了一下,实体类都不需要
长宽高作为实体类的三个字段属性,a,b,c , 体积就是 t = abc ,面积就是m = 2*(ab+bc+c*a) ,写个测试类,一分钟写完
class Cuboid{
private double length;
private double width;
private double height;
public double surfaceArea(){
return 2*(this.length + this.width + this.height);
}
public double volume(){
return this.length * this.width * this.height;
}
}