01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
package agent.one;
import agent.Agent;
import agent.TimeServer;
import agent.TimeServerLinked;

public class Main {
  public static void main (String[] args) {
    TimeServer time = new TimeServerLinked();
    Agent a = new Tiger(time);
    time.enqueue(0,a);
    time.run(100);
  }
}

class Tiger implements Agent {
  private TimeServer time;
  public Tiger(TimeServer time) { this.time = time; }
  public void run() {
    System.out.println("It's " + time.currentTime() + " and I'm alive!");
    time.enqueue(10+time.currentTime(), this);
  }
}