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.
21 lines
532 B
21 lines
532 B
// 文件名:Main.java
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
// 创建具体图形对象
|
|
Shape c = new Circle(5);
|
|
Shape r = new Rectangle(4, 6);
|
|
Shape t = new Triangle(3, 8);
|
|
|
|
// 使用工具类统一处理
|
|
ShapeUtil util = new ShapeUtil();
|
|
|
|
System.out.print("圆形 -> ");
|
|
util.printArea(c);
|
|
|
|
System.out.print("矩形 -> ");
|
|
util.printArea(r);
|
|
|
|
System.out.print("三角形 -> ");
|
|
util.printArea(t);
|
|
}
|
|
}
|