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.

25 lines
538 B

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();
}
}