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.
17 lines
367 B
17 lines
367 B
public class Triangle extends Shape {
|
|
// 私有属性:底、高
|
|
private double base;
|
|
private double height;
|
|
|
|
// 构造方法
|
|
public Triangle(double base, double height) {
|
|
this.base = base;
|
|
this.height = height;
|
|
}
|
|
|
|
// 重写父类方法
|
|
@Override
|
|
public double getArea() {
|
|
return base * height / 2;
|
|
}
|
|
}
|