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
477 B
18 lines
477 B
public class Test {
|
|
public static void drawShape(Shape s) {
|
|
s.draw();
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
// 创建不同的形状对象
|
|
Shape circle = new Circle();
|
|
Shape rectangle = new Rectangle();
|
|
|
|
// 测试drawShape方法
|
|
System.out.println("测试绘制圆形:");
|
|
drawShape(circle);
|
|
|
|
System.out.println("测试绘制矩形:");
|
|
drawShape(rectangle);
|
|
}
|
|
}
|
|
|