agent CounterAgent extends Agent implements GenericCounter { #handles event CounterEvent; #uses plan CounterPlan; #posts event CounterEvent ev; private int currentCount; public CounterAgent(String name){ super(name); //give a name for the agent this.currentCount = 0; } public void countNext(){ this.currentCount++; System.out.println("Current number is " + this.currentCount); postEvent( ev.nextEvent() ); } public int getCurrentCount(){ return this.currentCount; } public void startAgent(){ // this inherited method will be called automatically once an instance of this agent is created. So, you don't need to explicitly call this method System.out.println("The agent starts..."); super.startAgent(); countNext(); } public void die(){ System.out.print("The agent is going to die... "); this.finish(); // the "finish" method is from the Agent super class System.out.println("The agent died"); System.exit(0); } public static void main(String[] args){ CounterAgent counterAgent = new CounterAgent("My Counter Agent"); } }