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.
14 lines
384 B
14 lines
384 B
public class ShapeTest{
|
|
// 统一绘制方法
|
|
public static void drawShape(Shape s) {
|
|
s.draw();
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
Shape circle = new Circle();
|
|
Shape rectangle = new Rectangle();
|
|
|
|
drawShape(circle); // 输出:绘制一个圆形 🟡
|
|
drawShape(rectangle); // 输出:绘制一个矩形 🟦
|
|
}
|
|
}
|