亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? livingbeing.java

?? exercie 8 ssd1 Object-Oriented Programming and Design Introduction This course introduces students
?? JAVA
字號:
/*!Begin Snippet:LivingBeing*/
/*
 * Created on Jul 4, 2003
 *
 */

/**
 * Each living being lives in a location (row, column) at any given time. 
 * More than one living being can be in a location. E.g.: algae and fish.
 * Depending on the species, living beings could move. 
 * <p>
 * Each living being has some energy level. If the energy level falls below
 * the minimum needed to live, it dies. When a living being dies, it is deleted
 * from the simulation.
 * </p>
 * 
 * @author iCarnegie av
 */
public class LivingBeing {

	/**
	 * The living being is born "alive". 
	 * Then it dies, becoming a corpse. 
	 */
	protected static final String ALIVE = "alive";

	/**
	 * The living being is born "alive". 
	 * Then it dies, becoming a "dead" corpse. 
	 */
	protected static final String DEAD = "dead";

	/**
	 * Row-wise location of the living being
	 */
	protected int row;

	/**
	 * Column-wise location of the living being
	 */
	protected int column;

	/**
	 * Is the living being dead or alive?
	 */
	private String deadOrAlive;
	
	/**
	 * Amount of energy the living being has.
	 */
	private int energy;

	/**
	 * Age expressed as blocks of time lived
	 */
	private int age = 0;

	/**
	 * Name of this living being.
	 */
	private final String name;

	/**
	 * The simulation to which this living being belongs.
	 * This is needed so the living being can send a message 
	 * to simulation and ask
	 * for prey (or predator) in the neighboring locations. 
	 * Prey is food. Food is good!
	 */
	protected Simulation simulation;

	/**
	 * Minimum energy level needed to survive.
	 * The minimum could increase as the individual grows.
	 */
	protected int minEnergy;
	
	/**
	 * Maximum energy level that the living being could carry.
	 * The maximum could change as the individual grows.
	 */
	protected int maxEnergy;


	/**
	 * Create a living being at a given location with a 
	 * given energy and store the simulation to which the living being belongs.
	 * Cap row and column within lake boundary.
	 *  
	 * @param initialRow - the row location of living being
	 * @param initialColumn - the column locaiton of living being
	 * @param initialSimulation - the simulation to which this being belongs
	 * @param initialName - name of the living being
	 * @param initialMinEnergy - minimum energy to survive
	 * @param initialMaxEnergy - max energy the living being can carry 
	 */
	protected LivingBeing(
		int initialRow,
		int initialColumn,
		Simulation initialSimulation,
		String initialName,
		int initialMinEnergy,
		int initialMaxEnergy) {
			
		simulation = initialSimulation;

		deadOrAlive = ALIVE; 

		// Set the Row within bounds
		if (initialRow > simulation.getLastRow()) {
			row = simulation.getLastRow();
		} else if (initialRow < simulation.getFirstRow()) {
			row = simulation.getFirstRow();
		} else {
			row = initialRow;
		}

		// Set the Column within bounds
		if (initialColumn > simulation.getLastColumn()) {
			column = simulation.getLastColumn();
		} else if (initialColumn < simulation.getFirstColumn()) {
			column = simulation.getFirstColumn();
		} else {
			column = initialColumn;
		}

		// Set the minEnergy and maxEnergy
		minEnergy = initialMinEnergy;
		maxEnergy = initialMaxEnergy;

		energy =
			simulation.getRand().nextInt(maxEnergy - minEnergy) + minEnergy;

		age = 0;
		name = initialName;
	}

	/**
	 * Create an organism that belongs to a specified species at
	 * a specified location and add it to the specified simulation.
	 * 
	 * @param simulation - the simulation this organism belongs to
	 * @param species - the organism's species
	 * @param value - row and column values specified as String from HTML form.
	 * row value is the last two digits, 
	 * column value is given in the remaining digits.
	 */
	public static void createLivingBeing(
		Simulation sim,
		String species,
		String value) {

		int rowAndCol = Integer.parseInt(value);
		int row = rowAndCol / 100;
		int column = rowAndCol - (100 * row);

		if (species.equals("algae")) {
			sim.addLivingBeing(new AlgaeColony(row, column, sim));
		}

		if (species.equals("catfish")) {
			sim.addLivingBeing(new Catfish(row, column, sim));
		}

		if (species.equals("crocodile")) {
			sim.addLivingBeing(new Crocodile(row, column, sim));
		}
	}
	
	/**
	 * Get the row at which the living being is located 
	 * 
	 * @return - the row of the living being's location. 
	 */		
	public int getRow() {
		return row;
	}

	/**
	 * Get the column at which the living being is located
	 * 
	 * @return - the column of the living being's location. 
	 */		
	public int getColumn() {
		return column;
	}

	/**
	 * Get the living being's age
	 * 
	 * @return the age of the living being expressed in blocks of time
	 */
	public int getAge() {
		return age;
	}

	/**
	 * Color of the living being expressed in hex notation.
	 * For example, the "green-est" color is "#00FF00",
	 * "blue-est" is "#0000FF", the "red-est" is "#FF0000".
	 * 
	 * @return the rgb color in hex notation. preceded by a pound character '#'
	 */
	public String getColor() {
		return "#FFFFFF"; // default is white.
	}

	/**
	 * Get the name of this living being
	 * 
	 * @return the name of the living being.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Get the filename that contains the image of the living being
	 * 
	 * @return the image of the living being.
	 */
	public String getImage() {
		return "/blank.gif";
	}

	/**
	 * Get the preferred display mechanism for living being
	 * 
	 * @return one of the constants IMAGE or COLOR, 
	 * depending on the display mechanism for the living being.
	 */
	public String getDisplayMechanism() {
		return Simulation.IMAGE;
	}
	
	/**
	 * Get the minimum energy needed to live.
	 * 
	 * @return the minimum energy needed for the living being to live.
	 */
	protected int getMinEnergy() {
		return minEnergy;
	}
	
	/**
	 * get the maximum energy that the living being can carry.
	 * 
	 * @return the maximum energy the living being can carry.
	 */
	protected int getMaxEnergy() {
		return maxEnergy;
	}
	

	/**
	 * Returns the species.
	 * 
	 * @return the species
	 */
	public String getSpecies() {
		return "Unknown";
	}

	/**
	 * Get the energy currently carried by the living being.
	 * 
	 * @return current energy level of the organism
	 */
	public int getEnergy() {
		return energy;
	}

	/**
	 * Sets energy level.
	 * If new energy level is less than minimum energy level, the organism dies.
	 * New energy level is capped at maximum energy level.
	 */
	protected void setEnergy(int newEnergy) {
		
		if (newEnergy < getMinEnergy()) {
			energy = newEnergy;
			die();
		} else if (newEnergy > getMaxEnergy()) {
			energy = getMaxEnergy();
		} else {
			energy = newEnergy;
		}
	}

	/**
	 * Die: Change the deadOrAlive to DEAD.
	 */
	protected void die() {
		deadOrAlive = DEAD;
	}

	/**
	 * Is the living being dead?
	 * 
	 * @return <code>true</code> if dead. <code>false</code>, otherwise.
	 */
	public boolean isDead() {
		return (deadOrAlive == DEAD);
	}

	/**
	 * The living being's age increases by one time block.
	 */
	public void liveALittle() {
		age = age + 1;
	}
}
/*!End Snippet:LivingBeing*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
奇米影视7777精品一区二区| 日本强好片久久久久久aaa| 精品动漫一区二区三区在线观看| 欧美日本乱大交xxxxx| 欧美午夜理伦三级在线观看| 色婷婷综合激情| 日本精品一区二区三区高清| 91年精品国产| 91亚洲精品久久久蜜桃网站 | 日本网站在线观看一区二区三区| 依依成人精品视频| 亚洲综合图片区| 亚洲成av人影院在线观看网| 亚洲国产综合91精品麻豆| 午夜视黄欧洲亚洲| 奇米777欧美一区二区| 麻豆精品一区二区三区| 久久99热99| 精品一区二区三区免费视频| 久久精品国产99国产| 国产精品毛片大码女人| 国产精品美女久久福利网站| 久久久久国产精品麻豆ai换脸 | 色婷婷精品大视频在线蜜桃视频 | 91精品国产91久久久久久最新毛片 | 欧美成人一区二区三区在线观看| 91色在线porny| 欧美日韩中文另类| 欧美一区二区视频在线观看2020| 日韩美女在线视频| 久久婷婷成人综合色| 成人欧美一区二区三区黑人麻豆| 亚洲欧美激情一区二区| 一区在线观看视频| 午夜在线成人av| 日韩福利视频导航| 国产成人精品影视| 色综合天天做天天爱| 91精品国产综合久久精品app| 欧美肥妇free| 中文字幕精品一区二区精品绿巨人 | 日韩欧美国产麻豆| 日韩欧美在线1卡| 国产精品久久久99| 亚洲免费在线播放| 免费久久精品视频| 国产成人精品亚洲777人妖| 在线免费不卡电影| 日韩欧美国产一区在线观看| 欧美mv和日韩mv的网站| 国产亚洲精品aa午夜观看| 亚洲欧美日韩在线不卡| 日韩av一级电影| 成人av影院在线| 在线观看不卡视频| 精品国产免费一区二区三区四区 | 亚洲v日本v欧美v久久精品| 免费人成黄页网站在线一区二区 | 色拍拍在线精品视频8848| 日韩精品最新网址| 欧美韩日一区二区三区四区| 午夜精品国产更新| 国产·精品毛片| 欧美一级理论片| 国产精品久久久久7777按摩| 亚洲午夜在线电影| 成人性生交大片免费看中文网站| 欧美在线观看你懂的| 国产精品免费视频一区| 日韩成人av影视| 色综合 综合色| 精品电影一区二区| 视频一区二区中文字幕| www.综合网.com| 欧美α欧美αv大片| 一区二区三区免费观看| 美女视频黄免费的久久| 在线观看一区不卡| 国产欧美一区二区精品久导航| 日韩不卡在线观看日韩不卡视频| kk眼镜猥琐国模调教系列一区二区 | 国产精品灌醉下药二区| 日本不卡一二三| 欧美日韩在线播| 国产色婷婷亚洲99精品小说| 久久综合综合久久综合| 欧美综合久久久| 一区av在线播放| 99麻豆久久久国产精品免费优播| 精品伦理精品一区| 亚洲男同性视频| 成人午夜av电影| 日韩欧美国产一二三区| 丝袜亚洲另类欧美| 色嗨嗨av一区二区三区| 国产精品毛片无遮挡高清| 久久99国产精品久久| 日韩一区二区在线看| 一区二区欧美在线观看| 色悠悠久久综合| 国产精品欧美一级免费| 51精品国自产在线| 亚洲精品成人在线| 日本道精品一区二区三区| 国产精品视频第一区| 日本中文字幕不卡| 日韩视频永久免费| 日韩va亚洲va欧美va久久| 欧美日韩国产乱码电影| 亚洲一区二区影院| 欧美视频一区在线| 一区二区在线免费观看| 91成人免费网站| 亚洲欧美日韩中文字幕一区二区三区 | 欧美日韩国产成人在线91| 亚洲成人1区2区| 欧美老女人第四色| 看电视剧不卡顿的网站| 日韩精品一区二区三区swag| 久久er99热精品一区二区| 欧美一区二区免费| 韩国av一区二区三区在线观看| 日韩女同互慰一区二区| 美女性感视频久久| 欧美一级专区免费大片| 午夜精品一区二区三区免费视频| 欧美高清www午色夜在线视频| 香蕉影视欧美成人| 欧美成人精品3d动漫h| 精品一区二区三区视频在线观看| 91精品国产日韩91久久久久久| 午夜精品久久久久久久蜜桃app| 欧美日韩精品一区二区天天拍小说| 亚洲福利国产精品| 欧美在线免费观看视频| 老司机精品视频一区二区三区| 久久精品男人的天堂| 成人手机在线视频| 国产精品家庭影院| 91日韩精品一区| 日韩激情在线观看| 欧美成人国产一区二区| 3751色影院一区二区三区| 精品国产露脸精彩对白| 成人av片在线观看| 亚洲精品写真福利| 欧美巨大另类极品videosbest | 视频在线在亚洲| 国产精品天干天干在线综合| 97国产精品videossex| 日本va欧美va瓶| 国产拍揄自揄精品视频麻豆| 欧美日韩综合不卡| 精品亚洲国产成人av制服丝袜| 国产精品欧美久久久久无广告 | 日本成人在线电影网| 国产精品视频看| 欧美亚洲另类激情小说| 国产一区二区三区免费| 亚洲欧美一区二区视频| 欧美大度的电影原声| 91免费看视频| 国内精品伊人久久久久av一坑 | 欧美日韩午夜在线| 国产xxx精品视频大全| 亚洲午夜久久久久久久久电影院 | 国产一区二区影院| 亚洲午夜精品网| 久久久久久久久久久99999| 欧美日韩另类国产亚洲欧美一级| 久久66热re国产| 亚洲第四色夜色| 国产精品网站在线观看| 精品免费99久久| 欧美伊人精品成人久久综合97| 成人一级视频在线观看| 成人免费毛片片v| 精东粉嫩av免费一区二区三区| 亚洲欧美综合另类在线卡通| 精品国产凹凸成av人网站| 日本高清成人免费播放| 国产91清纯白嫩初高中在线观看| 亚洲国产视频网站| 亚洲另类中文字| 久久综合一区二区| 欧美一级黄色大片| 色诱视频网站一区| 91小视频在线免费看| 国产在线精品视频| 麻豆视频观看网址久久| 亚洲精品乱码久久久久久日本蜜臀| 久久久久99精品一区| 欧美高清视频一二三区 | 欧美最新大片在线看 | 久久久精品蜜桃| 久久伊人蜜桃av一区二区| 欧美日本在线一区| 欧美精品一二三| 在线精品观看国产| 欧美系列亚洲系列|