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.
18 lines
521 B
18 lines
521 B
public class Test {
|
|
public static void main(String[] args) {
|
|
// 创建不同图形对象
|
|
Shape circle = new Circle(3);
|
|
Shape rect = new Rectangle(4, 5);
|
|
Shape triangle = new Triangle(3, 4, 5);
|
|
|
|
// 统一调用工具类打印面积
|
|
System.out.println("圆形:");
|
|
ShapeUtil.printArea(circle);
|
|
|
|
System.out.println("矩形:");
|
|
ShapeUtil.printArea(rect);
|
|
|
|
System.out.println("三角形:");
|
|
ShapeUtil.printArea(triangle);
|
|
}
|
|
}
|