annotate src/samer/core_/CompoundAgent.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
children
rev   line source
samer@0 1 /*
samer@0 2 * CompoundAgent.java
samer@0 3 *
samer@0 4 * Copyright (c) 2000, Samer Abdallah, King's College London.
samer@0 5 * All rights reserved.
samer@0 6 *
samer@0 7 * This software is provided AS iS and WITHOUT ANY WARRANTY;
samer@0 8 * without even the implied warranty of MERCHANTABILITY or
samer@0 9 * FITNESS FOR A PARTICULAR PURPOSE.
samer@0 10 */
samer@0 11
samer@0 12 package samer.core;
samer@0 13
samer@0 14 /** An Agent that is a composition of two given Agents. */
samer@0 15 public class CompoundAgent implements Agent
samer@0 16 {
samer@0 17 Agent a1, a2;
samer@0 18
samer@0 19 public CompoundAgent(Agent a1,Agent a2) { this.a1=a1; this.a2=a2; }
samer@0 20
samer@0 21 /** This reports the commands from both the child agents. Duplicate
samer@0 22 commands are not removed. */
samer@0 23 public void getCommands(Registry r) { a1.getCommands(r); r.group(); a2.getCommands(r); }
samer@0 24
samer@0 25 /** Forwards the the command on to BOTH child agents in the order specified
samer@0 26 in the constructor. */
samer@0 27 public void execute( String name, Environment env) throws Exception {
samer@0 28 a1.execute(name,env);
samer@0 29 a2.execute(name,env);
samer@0 30 }
samer@0 31 }