Browse Source

W4-张馨月-作业提交

W4
张馨月 3 weeks ago
parent
commit
a72e1d1682
  1. 29
      w4/Triangle.java
  2. BIN
      w4/图形面积计算器_类图.png
  3. BIN
      w4/图形面积计算运行结果.png
  4. BIN
      w4/实验报告.docx

29
w4/Triangle.java

@ -0,0 +1,29 @@
/**
* 三角形已知底与高面积 = * / 2
*/
public class Triangle extends Shape {
private final double base;
private final double height;
public Triangle(double base, double height) {
if (base <= 0 || height <= 0) {
throw new IllegalArgumentException("底和高必须为正数");
}
this.base = base;
this.height = height;
}
public double getBase() {
return base;
}
public double getHeight() {
return height;
}
@Override
public double getArea() {
return base * height / 2.0;
}
}

BIN
w4/图形面积计算器_类图.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

BIN
w4/图形面积计算运行结果.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

BIN
w4/实验报告.docx

Binary file not shown.
Loading…
Cancel
Save