1.桥
public interface Bridge { void tagetLand(); }
桥的实现
public class Forest implements Bridge { public void tagetLand() { System.out.println("树林,吃食"); } }
动物
public abstract class Animal { public Bridge bridge; public abstract void willToDo(); }
动物实现
public class Chick extends Animal { public void willToDo() { System.out.println("过河"); } }
调用
Animal chick = new Chick(); chick.bridge = new Forest(); chick.willToDo(); chick.bridge.tagetLand();
常用于dao模式中