标签:cross ace bsp stat nbsp 才有 idg color static
桥接是先有桥,才有两端的东西(可以分离某个东西)
适配是先有两边的东西,才有适配器
package structural.pratice; public class BridatePMain { public static void main(String[] args) { BridgeP bp = new BridgePRight(); CrossBridge cross = new CrossBridge(bp); cross.goRight(); } } //目的地与桥绑定 interface BridgeP{ public void crossBridge(); } //在桥右边 class BridgePRight implements BridgeP{ @Override public void crossBridge() { System.out.println("我到了桥右边"); } } abstract class BridgePLeft{ protected BridgeP bp; public BridgePLeft(BridgeP bp){ this.bp = bp; } public abstract void goRight(); } class CrossBridge extends BridgePLeft{ public CrossBridge(BridgeP bp) { super(bp); } @Override public void goRight() { System.out.println("我要过桥"); bp.crossBridge(); } }
标签:cross ace bsp stat nbsp 才有 idg color static
原文地址:https://www.cnblogs.com/zzlcome/p/11423317.html