You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
370 B

public class Circle extends Shape {
// 私有属性:半径
private double radius;
// 构造方法:创建圆时必须传入半径
public Circle(double radius) {
this.radius = radius;
}
// 重写父类抽象方法,实现圆的面积计算
@Override
public double getArea() {
return Math.PI * radius * radius;
}
}