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

📄 simpleperson.java

📁 Eclipse+repastS
💻 JAVA
字号:
/* * 〤opyright 2008 Nick MallesonThis file is part of RepastCity.RepastCity is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.RepastCity is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along with RepastCity.  If not, see <http://www.gnu.org/licenses/>. */package repastcity.personcontext;import repast.simphony.engine.environment.RunEnvironment;import repastcity.ContextCreator;import repastcity.citycontext.House;import repastcity.citycontext.Route;public class SimplePerson {	private int id;	private String name;	private Route route;	// A Route object controls where this person goes and moves them around the city.		public SimplePerson() {	}	//@ScheduledMethod(start=1, priority=1, duration=1)	public void step() {				try {			//		System.out.println("Person: "+this.name+"("+this.id+") stepping");			// If this person doesn't have a route or they have reached their destination, then create a			// route to a new random house			if (this.route==null || this.route.atDestination())  {				House h = ContextCreator.getHouseContext().getRandomObject();				this.route = new Route(this, 						ContextCreator.getHouseGeography().getGeometry(h).getCentroid().getCoordinate());			}			this.route.travel(); // This will move the person towards their destination		}		catch (Exception e) {			// This is useful for debugging, pause the simulation if there was an error.			System.err.println("Person "+this.id+" ("+this.name+") had an error while travelling:");			e.printStackTrace();			RunEnvironment.getInstance().pauseRun();		}			}					/**	 * @return the iD	 */	public int getId() {		return id;	}	/**	 * @param id the iD to set	 */	public void setId(int id) {		this.id = id;	}	/**	 * @return the name	 */	public String getName() {		return name;	}	/**	 * @param name the name to set	 */	public void setName(String name) {		this.name = name;	}			}

⌨️ 快捷键说明

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