JavaLearning:代理设计模式

来源:互联网 发布:飞利浦淘宝旗舰店 编辑:程序博客网 时间:2024/05/16 12:21
interface Give{   public void giveMoney();}class RealGive implements Give{   public void giveMoney(){      System.out.println("getMonay");   }};class ProxyGive implements Give{   private Give give=null;   public ProxyGive(Give give){      this.give=give;   }   public void before(){     System.out.println("before");   }   public void giveMoney(){     this.before(); this.give.giveMoney(); this.after();   }   public void after(){     System.out.println("after");   }};public class Demo028{  public static void main(String[] args){    Give give=new ProxyGive(new RealGive());give.giveMoney();  }}

0 0
原创粉丝点击