如有帮助,点击我回答右上角【采纳】按钮。
public abstract class Shape {
protected int width;
protected int height;
public Shape(int width, int height) {
this.width = width;
this.height = height;
}
abstract double area();
}
public class Rectangle extends Shape{
public Rectangle(int width, int height) {
super(width, height);
}
@Override
double area() {
return width*height;
}
public void fill(String color){
System.out.println("长方形为"+color);
}
}