1 changed files with 25 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||
package w5; |
|||
|
|||
abstract class Shape{ |
|||
public abstract void draw(); |
|||
} |
|||
class Circle extends Shape{ |
|||
@Override |
|||
public void draw() { |
|||
System.out.println("画一个圆"); |
|||
} |
|||
} |
|||
class Rectangle extends Shape{ |
|||
@Override |
|||
public void draw() { |
|||
System.out.println("画一个矩形"); |
|||
} |
|||
} |
|||
class ShapeTest{ |
|||
public static void main(String[] args){ |
|||
Shape circle = new Circle(); |
|||
circle.draw(); |
|||
Shape rectangle = new Rectangle(); |
|||
rectangle.draw(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue