public class ShapeTest { public static void drawShape(Shape s) { s.draw(); } public static void main(String[] args) { // 创建形状对象 Shape myShape = new Shape(); Shape myCircle = new Circle(); Shape myRectangle = new Rectangle(); // 测试 drawShape 方法 System.out.println("测试 Shape 基类:"); drawShape(myShape); System.out.println("\n测试 Circle 子类:"); drawShape(myCircle); System.out.println("\n测试 Rectangle 子类:"); drawShape(myRectangle); } }