public abstract class AbstractCircle {
protected double radius;
public void setRadius(int radius){this.radius=radius;}
public double getRadius(){return radius;}
public abstract void render();
}
public class ConcreteCircle extends AbstractCircle {
public ConcreteCircle(){}
public ConcreteCircle(double radius){
this.radius=radius;
}
public void render(){
System.out.println("画一个半径"+getRadius()+"的实心圆");
}
}
public class HollowCircle extends AbstractCircle {
public HollowCircle() {
// TODO Auto-generated constructor stub
}
public HollowCircle(double radius){
this.radius=radius;
}
public void render(){
System.out.println("画出一个半径"+getRadius()+"的空心圆");
}
}
public class CircleDemo {
/**
* method description
* @version 0.1
* @date 2007-5-18
* @author liusx
*/
public static void main(String[] args) {
renderCircle(new ConcreteCircle(3.33));
renderCircle(new HollowCircle(10.2));
}
public static void renderCircle(AbstractCircle circle){
circle.render();
}
}
为什么在最后有句 public static void renderCircle(AbstractCircle circle){
circle.render();
是由什么意义啊 ?
请 指教下!!
----------------解决方案--------------------------------------------------------
多态啊
----------------解决方案--------------------------------------------------------
谢谢!!
----------------解决方案--------------------------------------------------------