1 changed files with 24 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||||
|
abstract class Shape{ |
||||
|
public abstract void draw(); |
||||
|
} |
||||
|
class Rectangle extends Shape{ |
||||
|
public void draw(){ |
||||
|
System.out.println("»Ò»¸ö¾ØÐÎ"); |
||||
|
} |
||||
|
} |
||||
|
class Circle extends Shape{ |
||||
|
public void draw(){ |
||||
|
System.out.println("»Ò»¸öÔ²"); |
||||
|
} |
||||
|
} |
||||
|
public class Main{ |
||||
|
public static void drawShape(Shape s){ |
||||
|
s.draw(); |
||||
|
} |
||||
|
public static void main(String[] args){ |
||||
|
Shape shape = new Rectangle(); |
||||
|
drawShape(shape); |
||||
|
Shape shape2 = new Circle(); |
||||
|
drawShape(shape2); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue