⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mailboxtry11.java

📁 一个agent 工具包,可以开发移动设备应用,考虑了安全措施
💻 JAVA
字号:
import SOMA.agent.*;
import SOMA.naming.*;

import java.util.*;

public class MailboxTry11 extends Agent {
	
	private PlaceID home;
	private AgentID parent;
	private int destinationIndex;
	private String manipulation = "";
	
	public void putArgument(Object obj) {
		
		Vector temp = (Vector) obj;
		home = (PlaceID) temp.get(0);
		parent = (AgentID) temp.get(1);
		destinationIndex = ((Integer) temp.get(2)).intValue();
		
	}
	
	public void run() {
		
		try {
			go((PlaceID) agentSystem.sharedObjects.get(destinationIndex), "buildString");
		} catch (CantGoException cge) {
			cge.printStackTrace();
		}
		
	}
	
	public void buildString() {
		
		Vector places = new Vector(Arrays.asList(agentSystem.getPlaces()));
		places.remove(agentSystem.getPlaceID());
		for (int index = places.size() - 1; index >= 0; index--) {
			PlaceID place = (PlaceID) places.get(index);
			manipulation += " " + place.toString();
		}
		
		try {
			go(home, "atHome");
		} catch (CantGoException cge) {
			cge.printStackTrace();
		}
	
	}
	
	public void atHome() {
		
		// Substitute the old object (a PlaceID) with the String previously built
		agentSystem.sharedObjects.remove(destinationIndex);
		agentSystem.sharedObjects.put(destinationIndex, manipulation);
		// the agent has done, and notifies it to its parent
		Message mex = new Message("lurker_agent_done", getID(), parent);
		agentSystem.sendMessage(mex);
	
	}
	
} // end MailboxTry11

⌨️ 快捷键说明

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