/** * 图形工具类,提供统一的面积打印方法 */ public class ShapeUtil { /** * 统一打印图形面积的方法,支持所有Shape子类 * @param shape 图形对象(Circle/Rectangle/Triangle) */ public static void printArea(Shape shape) { System.out.println("该图形的面积为:" + shape.getArea()); } }