8 changed files with 30 additions and 0 deletions
Binary file not shown.
@ -0,0 +1,6 @@ |
|||||
|
public class DrawCircle extends DrawShape { |
||||
|
@Override |
||||
|
public void draw() { |
||||
|
System.out.println("绘制圆形 O"); |
||||
|
} |
||||
|
} |
||||
Binary file not shown.
@ -0,0 +1,6 @@ |
|||||
|
public class DrawRectangle extends DrawShape { |
||||
|
@Override |
||||
|
public void draw() { |
||||
|
System.out.println("绘制矩形 □"); |
||||
|
} |
||||
|
} |
||||
Binary file not shown.
@ -0,0 +1,5 @@ |
|||||
|
public class DrawShape { |
||||
|
public void draw() { |
||||
|
System.out.println("绘制形状"); |
||||
|
} |
||||
|
} |
||||
Binary file not shown.
@ -0,0 +1,13 @@ |
|||||
|
public class ShapeTest { |
||||
|
public static void drawShape(DrawShape s) { |
||||
|
s.draw(); |
||||
|
} |
||||
|
|
||||
|
public static void main(String[] args) { |
||||
|
DrawShape circle = new DrawCircle(); |
||||
|
DrawShape rectangle = new DrawRectangle(); |
||||
|
|
||||
|
drawShape(circle); |
||||
|
drawShape(rectangle); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue