代理模式
package mode.proxy; /** * * 这里的代理模式是通过接口方式实现的 * * */ public interface NetWork { public void browser(); }
package mode.proxy; public class Real implements NetWork { @Override public void browser() { System.out.println("上网浏览信息"); } }
package mode.proxy; public class Proxy implements NetWork { private NetWork netWork; public Proxy(NetWork netWork) { this.netWork = netWork; } @Override public void browser() { checName(); this.netWork.browser(); } private void checName() { System.out.println("我检查了名字"); } }