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.
27 lines
534 B
27 lines
534 B
package Homework;
|
|
|
|
public 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 Main{
|
|
public static void drawShape(shape s){
|
|
s.draw();
|
|
}
|
|
public static void main(String[]args){
|
|
drawShape(new Circle());
|
|
drawShape(new Rectangle());
|
|
}
|
|
}
|