文章标题

来源:互联网 发布:淘宝卖家版电脑版 编辑:程序博客网 时间:2024/06/07 21:24

java设计模式-代理设计模式

public class Test{
pubic static void main(String args[]){
NetWork net = new Proxyd(new Real());
net.broswer();
}
}
interface NetWork{
public void broswer();
}
class Real implements NetWork{
public void broswer(){ //实现类
System.out.println(“search information”);
}
}
class Proxy implements NetWork{ //代理类
private NetWork network;
public Proxy(NetWork network){
this.network = network;
}
public void check(){
System.out.println(“check information”);
}
public void broswer(){
this.check();
this.network.broswer();
}

}

原创粉丝点击