代理设计由一个代理主题来操控真实主题,真实主题执行具体的业务操作
interface Network{//定义一个上网接口 public void browse(); } class Real implements Network{4 public void browse(){ System.out.println("用户浏览页面"); } } class DaiLi implements Network{ private Network network; public DaiLi(Network network){ this.network = network; } public void yanZheng(){ System.out.println("验证用户是否符合上网条件"); } public void browse(){ this.yanZheng(); this.network.browse(); } } public class User1{ public static void main(String[] args){ Network net = null; net = new DaiLi(new Real()); net.browse(); } }
以粮为纲全面发展