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();
}
}