class cbox {
constructor(length, width, height) {
this.length = length;
this.width = width;
this.height = height;
}
// method
volume() {
return this.length * this.width * this.height;
}
// 按照长方体去计算的表面积
surfaceArea() {
return (
this.length * this.width * 2 +
this.length * this.height * 2 +
this.width * this.height * 2
);
}
}
第二个自己来吧,尝试一下,不尝试永远学不会