代理设计模式

 1 interface A
 2 {public void get();
 3 }
 4 class B implements A
 5 {public void get(){
 6     System.out.println("出席活动");
 7 }
 8 }
 9 class C implements A
10 {private A a;
11  public C(A a){
12    this.a=a;
13    }
14 public void print (){
15    System.out.println("接到媒体通知");
16    }
17 public void get(){
18    this.print();
19    this.a.get();
20    this.stop();
21    }
22 public void stop(){
23     System.out.println("结束");
24        }
25 }
26 public class vvv
27 {public static void main(String args[]){
28     A a=new C(new B());
29     a.get();
30     }
31 }

 

posted @ 2016-09-27 17:26  as145  阅读(110)  评论(0编辑  收藏  举报