代理模式

设计模式值代理模式

package test;//主题=代理主题(真实主题)

interface Subject{
	
}
class RealSubject implements Subject{

}
class ProxySubject{
	private Subject subject;
	public ProxySubject(){}
	public ProxySubject(Subject subject){
		this.subject=subject;
	}
	public void start(){
		System.out.println("启动");
	}
}

public class Dailimoshi {
	public static void main(String[] args) {
		Subject realSubject=new RealSubject();
		new ProxySubject(realSubject).start();
	}
}

  

posted @ 2017-10-11 16:09  Oracle&Java  阅读(220)  评论(0编辑  收藏  举报