在說明柔性多態(tài)之前先看看下面多態(tài)的設(shè)計(jì)
一般常規(guī)的多態(tài)程序設(shè)計(jì),首先定義多態(tài)接口
public interface IShape3 { public float getArea(); }
然后在實(shí)體類中重寫多態(tài)函數(shù)
public class Circle3 implements IShape3 { float r; public Circle3(float r){ this.r = r; } public float getArea(){ return r*r*(float)Math.PI; } }
public class Rect3 implements IShape3 { private float width,height; public Rect3(float width,float height){ &