lurkertryagent.java

来自「一个agent 工具包,可以开发移动设备应用,考虑了安全措施」· Java 代码 · 共 43 行

JAVA
43
字号
import SOMA.agent.*;
import SOMA.naming.*;

/**
 * Coupled with BaseTryAgent, this agent realizes a first try to create and
 * move new agents from an initial place.
 *
 * @author	Giulio Piancastelli
 * @version	0.1 - Wednesday 13th February, 2002
 */
public class LurkerTryAgent extends Agent {
	
	// Serializable fields
	private PlaceID myHome; // the place where the lurker was created
	private PlaceID myNextPlace; // the place where the lurker was said to go
	
	public void putArgument(Object obj) {
		
		// the object is a Vector
		java.util.Vector v = (java.util.Vector) obj;
		myHome = (PlaceID) v.get(0);
		myNextPlace = (PlaceID) v.get(1);
		
	}
	
	public void run() {
		
		try {
			go(myNextPlace, "greetings");
		} catch (CantGoException cge) {
			cge.printStackTrace();
		}
		
	}
	
	public void greetings() {
		
		agentSystem.getOut().println("I come from " + myHome + "- I was said to go to " + myNextPlace + " and I am now in " + agentSystem.getPlaceID());
	
	}
	
} // end LurkerTryAgent

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?