001package agent.two; 002import agent.Agent; 003import agent.TimeServer; 004import agent.TimeServerLinked; 005 006public class Main { 007 public static void main (String[] args) { 008 World w = World.instance; 009 Agent a = new Tiger(); 010 w.time().enqueue(0,a); 011 w.time().run(100); 012 } 013} 014 015interface World { 016 public static final World instance = new WorldObj(); 017 public TimeServer time(); 018 public Object[][] space(); 019} 020 021class WorldObj implements World { 022 private TimeServer time = new TimeServerLinked(); 023 private Object[][] space = new Object[100][100]; 024 public TimeServer time() { return time; } 025 public Object[][] space() { return space; } 026} 027 028class Tiger implements Agent { 029 public void run() { 030 World w = World.instance; 031 System.out.println("It's " + w.time().currentTime() + " and I'm alive!"); 032 w.time().enqueue(10+w.time().currentTime(), this); 033 } 034}