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
456 B
18 lines
456 B
package w4;
|
|
|
|
public class ShapeUtil {
|
|
public static void printArea(Shape shape) {
|
|
System.out.println("该图形的面积为:" + shape.getArea());
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
Shape circle = new Circle(5);
|
|
printArea(circle);
|
|
|
|
Shape rectangle = new Rectangle(4, 6);
|
|
printArea(rectangle);
|
|
|
|
Shape triangle = new Triangle(3, 8);
|
|
printArea(triangle);
|
|
}
|
|
}
|
|
|