我收到以下错误:“Square 类中的构造函数 Square 不能应用于给定类型;必需:double,double found:无参数原因:实际参数列表和形式参数列表的长度不同”
我找不到任何我错过双打的地方,所以我很困惑为什么这不开心。谁能指引我正确的方向?
提前致谢!
class Square {
private double Height;
private double Width;
private double SurfaceArea;
Square(double sqHeight, double sqWidth) {
this.Height = sqHeight;
this.Width = sqWidth;
}
// Get square/cube height
double getHeight() {
return Height;
}
// Get square/cube width
double getWidth(){
return Width;
}
// Computer surface area
double computeSurfaceArea(){
SurfaceArea = Width * Height;
return SurfaceArea;
}
}
class Cube extends Square {
private double Height;
private double Width;
private double Depth;
private double SurfaceArea;
**// Error occurs here**
Cube(double cuHeight, double cuWidth, double cuDepth) {
this.Height = cuHeight;
this.Width = cuWidth;
this.Depth = cuDepth;
}
double getDepth() {
return Depth;
}
@Override
double computeSurfaceArea(){
SurfaceArea = (2 * Height * Width) +
(2 * Width * Depth) +
(2 * Depth * Height);
return SurfaceArea;
} }