【发布时间】:2016-07-23 11:15:46
【问题描述】:
public abstract class Shape{
protected Point position;
public Shape (Point p)
{
this.position=new Point(p);
}
public abstract int getArea();
public abstract int gerPerimeter();
public abstract boolean overlap(Shape other);
}
public class Rectangle extends Shape
{
public int width;
public int height;
public Rectangle(Point position,int width,int height)
{
super(position);
this.width=width;
this.height=height;
}
@Override
public int getArea()
{
return width*height;
}
@Override
public int getPerimeter()
{
return width*2+height*2;
}
@Override
public boolean overlap(Rectangle other)
{
return false;
}
}
Rectangle.java:1: 错误:Rectangle 不是抽象的,并且不会覆盖 Shape 中的抽象方法重叠(Shape)
公共类 Rectangle 扩展 Shape
^Rectangle.java:17: 错误:方法没有覆盖或实现超类型中的方法
@Override
^Rectangle.java:22: 错误:方法没有覆盖或实现超类型中的方法
@Override
^3 个错误
【问题讨论】: