Java报错:java: 无法将类 PlainRect中的构造器 PlainRect应用到给定类型;
需要: 没有参数
找到: int ,int ,int, int
原因: 实际参数列表和形式参数列表长度不同
public class Rect {
public double width;
public double height;
public void Rect(){
this.height=10;
this.width=10;
}
public void Rect(double width,double height){
this.width=width;
this.height=height;
}
public double area(){
double s;
s=width*height;
return s;
}
public double perimeter(){
double c;
c=2*width+2*height;
return c;
}
}
class PlainRect extends Rect{
public double startX;
public double startY;
public void PlainRect(){
}
public void PlainRect(double startX,double startY,double width,double height){
this.startX=startX;
this.startY=startY;
this.width=width;
this.height=height;
}
public Boolean isInside(double x,double y){
if(x>=startX&&x<=(startX+width)&&y<=startY&&y>=(startY-height)){
return true;
}else
return false;
}
}
class TestPR{
public static void main(String[] args){
PlainRect PR=new PlainRect(50,50,30,20);
}
}
定义的是double类型,传的参数怎么是int类型