public class Tank implements Moveable{
@Override
public void move() {
System.out.println("我是坦克,所向披靡,进攻中!");
try {
Thread.sleep(new Random().nextInt(1000));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public class ProxyTankTime implements Moveable{
private Moveable move;
public ProxyTankTime(Moveable move){
this.move=move;
}
@Override
public void move(){
long start=System.currentTimeMillis();
System.out.println("坦克开始移动....");
move.move();
System.out.println("移动的时间:"+(System.currentTimeMillis()-start));
}
}
public interface Moveable { void move();}public class Tank implements Moveable{ @Override public void move() { System.out.println("我是坦克,所向披靡,进攻中!"); try { Thread.sleep(new Random().nextInt