JAVA找不到符号构造函数
关注:52 答案:2 mip版
解决时间 2021-02-05 09:13
提问者彼岸独舞
2021-02-05 00:06
class Rect
{
private double length;
private double width;
public Rect(double length,double width)
{
this.width=width;
this.length=length;
}
public double getLength()
{
return length;
}
public double getWidth()
{
return width;
}
public void setLength(double length)
{
this.length=length;
}
public void setWidth(double width)
{
this.width=width;
}
public double girth(double Girth)
{
Girth=(width+length)*2;
return Girth;
}
public double area(double Area)
{
Area=width*length;
return Area;
}
}
class PlainRect extends Rect
{
private double startX;
private double startY;
public PlainRect(double length,double width,double startX,double startY)
{
setWidth(width);
setLength(length);
this.startX=startX;
this.startY=startY;
}
public PlainRect()
{
setLength(0);
setWidth(0);
startX=0;
startY=0;
}
public boolean isInside(double x,double y)
{
if(x>=startX&&x<=(startX+getLength())&&y>=startY&&y<=(startY+getWidth()))
{
return true;
}
else
return false;
}
}
错误:Rect.java:44:cannot resolve symbol
symbol:constructor Rect()
location:class Rect {
^
Rect.java:51:cannot resolve symbol
symbol:constructor Rect()
location:class Rect {
^
2 erroes
最佳答案
二级知识专家柒夏锦年
2021-02-05 00:29
public Rect(){
}
在Rect中添加无参数的构造
全部回答
1楼輓畱嶼赱
2021-02-05 01:36
在父类中,添加无参数的构造。
public rect(){
}
我要举报
如以上问答内容为低俗/色情/暴力/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!
→点此我要举报以上信息!←
推荐资讯
大家都在看