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.
13 lines
368 B
13 lines
368 B
public class ShapeUtil {
|
|
|
|
public void printArea(Shape shape) {
|
|
System.out.println("图形的面积为:" + shape.getArea());
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
ShapeUtil util = new ShapeUtil();
|
|
util.printArea(new Circle(5));
|
|
util.printArea(new Rectangle(4, 3));
|
|
util.printArea(new Triangle(3, 4));
|
|
}
|
|
}
|
|
|