public interface Selectable {
boolean getSelected();
void setSelected();
Shape contains(int x, int y);
}
public class Square extends Rectangle implements Selectable {
int side;
boolean selected;
public Square(int side){
super(side);
this.side = side;
}
public String toString(){
return " is square with side: " + side + ". It's area is: " + getArea() + "\n";
}
public void setSelected(boolean selected){
this.selected = selected;
}
public boolean getSelected(){
return selected;
}
public Shape contains(int x, int y){
}
}
没有编译
error: Square is not abstract and does not override abstract method setSelected() in Selectable
如何解决此错误?
答案 0 :(得分:2)
在您的界面中更改
void setSelected();
到
void setSelected(boolean selected);