资源简介
SSD1【Unit3】答案【Exercise8,Practical Quiz 8】
代码片段和文件信息
import java.util.Vector;
/**
* Catfish - simulates a catfish - can swim eat and consume
* energy in the process.
*
* @author A JiaYi
* Created on Jul 5 2003
*/
public class Catfish extends Animal {
/**
* Energy needed to swim in a block of time.
*/
private static final int ENERGY_TO_SWIM = 2;
/**
* Energy needed to look for food once.
*/
private static final int ENERGY_TO_LOOK_FOR_FOOD = 1;
/**
* Lowest possible energy needed for a baby to survive.
*/
private static final int BABY_MIN_ENERGY = 15;
/**
* Maximum energy that a baby can store.
*/
private static final int BABY_MAX_ENERGY = 100;
/**
* Eenrgy increment
*/
private static final int ENERGY_INCREMENT = 2;
/**
* Name of species
*/
private static final String SPECIES = “Catfish“;
/**
*
* Number of Catfish created
*/
private static int nCatfishCreated = 0;
/**
* Energy expended to eat once.
*/
private static final int ENERGY_TO_EAT = 1;
/**
* Energy gained when a full meal is eaten.
*/
private static final int ENERGY_IN_A_FULL_MEAL = 10;
/**
* Constructor. Initialize an algae to start life at a specified
* location with a specified energy. If location is out of bounds
* locate the catfish at the nearest edge.
*
* @param initialRow - the row at which the catfish is located
* @param initialColumn - the column at which the catfish is located
* @param initialSimulation - the simulation that the catfish belongs to
*/
public Catfish(
int initialRow
int initialColumn
Simulation initialSimulation) {
super(
initialRow
initialColumn
initialSimulation
SPECIES + nCatfishCreated
BABY_MIN_ENERGY
BABY_MAX_ENERGY);
++nCatfishCreated;
}
/**
* This individual belongs to the Catfish species.
*
* @return The string indicating the species
*/
public String getSpecies() {
return SPECIES;
}
/**
* Catfish should be displayed as an image.
*
* @return a constant defined in {@link Simulation#IMAGE Simulation} class
*/
public String getDisplayMechanism() {
return Simulation.IMAGE;
}
/**
* Get the image of the catfish
*
* @return filename of Catfish image
*/
public String getImage() {
if (getDirection() == RIGHT) {
return “/Catfish-right.gif“;
}
if (getDirection() == LEFT) {
return “/Catfish-left.gif“;
}
if (getDirection() == UP) {
return “/Catfish-up.gif“;
}
if (getDirection() == DOWN) {
return “/Catfish-down.gif“;
}
return “Catfish-right.gif“;
}
/**
* Look for food in the neighborhood. Consume some energy in the process.
*
* @return a neighboring living being that is food.
*/
private LivingBeing lookForFoodInNeighborhood() {
int neighborIndex;
// Looking for food consumes energy.
setEnergy(getEnergy() - ENERGY_TO_LOOK_FOR_FOOD);
if
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4340 2005-12-15 19:07 Unit3\EX8\Catfish.java
文件 4333 2005-12-15 19:06 Unit3\EX8\Crocodile.java
文件 36 2007-07-04 22:01 Unit3\MC_Answer.txt
文件 925 2005-12-15 19:46 Unit3\PQ8\ContractEmployee.java
文件 595 2005-12-15 16:36 Unit3\PQ8\Employee.java
文件 2654 2005-12-15 18:58 Unit3\PQ8\Payroll.java
文件 389 2005-12-15 16:48 Unit3\PQ8\RegularEmployee.java
目录 0 2007-06-05 13:09 Unit3\EX8
目录 0 2007-06-05 13:09 Unit3\PQ8
目录 0 2007-06-05 13:09 Unit3
----------- --------- ---------- ----- ----
13272 10
相关资源
- 西电微型计算机原理及接口技术部分
- C Primer plus第五版+答案高清晰
- 编译原理 课后习题答案 陈意云 张昱
- 西北工业大学数据结构及实验答案.
- 西工大noj答案完整版.doc
- 逻辑思维训练500题(带答案).zip
- 2020最新中科大组合数学引论课后答案
- 数据库原理及应用教程第4版微课版
- 国科大计算机网络题目参考答案2016年
- 胡乾斌版单片机课后习题答案
- 中南大学大学物理实验预习册习题答
- 数字逻辑与数学系统课后习题答案1
- 第三章习题参考答案.rar
- UiBot中级认证实践考试答案.zip
- 过程控制课后答案
- 通信原理复习题及答案.
- 全国计算机三级网络技术大题答案汇
- 无线通信基础习题答案 Fundamentals.of
- 2018中国大学MOOC(慕课)-《学习的革
- malloclab全套资料及参考答案
- 计算机网络自顶向下方法第六版习题
- 图论王树禾作业答案
- 软件工程期末考试复习题含答案
- 数据结构习题集及答案
- 集成数字电路课后习题及答案
- 形式语言与自动机期末试题及答案
- 微机原理与接口技术 答案 徐惠民 高
- 密码学答案 密码学答案
- C++程序设计实践教程答案
- 移动通信(第四版) 习题答案高清版
评论
共有 条评论