java学习

java学习

 

设计模式之静态代理

public interface MoveAble {
void move();
}
public class Tank1 implements MoveAble{
@Override
public void move() {
System.out.println("moving");
}
}
/**
 * 
 * 聚合
 *
 */
public class TankTime3 implements MoveAble{
private MoveAble t;
public TankTime3(){}
public TankTime3(MoveAble t){
this.t=t;
}
@Override
public void move() {
long s = System.currentTimeMillis();
t.move();
long e = System.currentTimeMillis();
System.out.println(e-s);
}
}
public class Test {
public static void main(String[] args) {
Tank1 t =new Tank1();
TankTime3 tt = new TankTime3(t);
tt.move();
}
}

posted on 2017-09-14 15:27 杨军威 阅读(116) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜