parent
91f4e9d149
commit
3c11abca26
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
package com.demo.tank.course9;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class TankEvent {
|
||||
private Timestamp timestamp;
|
||||
private Tank source;
|
||||
|
||||
public TankEvent(Timestamp timestamp, Tank source) {
|
||||
this.timestamp = timestamp;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public Timestamp getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public Tank getSource() {
|
||||
return source;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.demo.tank.course9;
|
||||
|
||||
public class TankFireHandler implements TankFireObserver{
|
||||
@Override
|
||||
public void actionOnFire(TankEvent event) {
|
||||
Tank tank = event.getSource();
|
||||
System.out.println("my tank fire time: " + event.getTimestamp());
|
||||
tank.fire();
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.demo.tank.course9;
|
||||
|
||||
public interface TankFireObserver {
|
||||
void actionOnFire(TankEvent event);
|
||||
}
|
Loading…
Reference in new issue