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.
9 lines
273 B
9 lines
273 B
public abstract class Shape {
|
|
// 抽象方法:计算面积,子类必须实现
|
|
public abstract double getArea();
|
|
|
|
// 通用方法:返回图形名称(子类可重写)
|
|
public String getName() {
|
|
return this.getClass().getSimpleName();
|
|
}
|
|
}
|
|
|