📄 catfishbonus.txt
字号:
Catfish
1) Behaviors:
* Constructor: Create an instance of Catfish at the specified row and column of the grid.
It will be have a certain amount of energy and an age 0. It will belong to the "Catfish" species.
It can be identified by a unique name. The maximum energy it can carry must be set to the maximum energy
allowed for a newborn Catfish. The minimum energy it needs to stay alive must be set to the minimum energy
required for an Catfish to stay alive.
* liveALittle. Live a block of time. If the Catfish is hungry then it looks for food in adjacent cell and
moves to that cell to eat if there is Algae available , otherwise moves to a random adjacent cell.
Relinquish necessary energy to swim and to eat and die if the energy falls bellow the minimum required
to stay alive. Increase the minumun and maximum energy of the Catfish. Returns nothing.
* die. Update living status to being dead. Returns nothing.
* isDead. Return the living status of the Catfish as a boolean.
* getRow. Return the row in which Catfish is located as an integer.
* getColumn. Return the column in which Catfish is located as an integer.
* getAge. Return the age of Catfish as an integer.
* getName. Return the unique name identifying the Catfish as a String.
* getImage. Return an image representing the Catfish.
* getColor. Return the color of the Catfish as a String.
* getEnergy. Return the current energy level as an integer.
* getDisplayMechanism. Return the mechanism used for displaying the Catfish,
which is either the name of an image file or a constant defined in the Simulation class.
* getSpecies. Return the species of the Catfish as a String.
* giveUpEnergy. Relinquish energy when it has eaten for a Crocodile. Returns the energy that it has in that moment.
* getMinEnergy. Return the minimum energy needed to stay alive as an integer.
* getMaxEnergy. Return the maximum energy that can be carried as an integer.
* setEnergy. Set the energy level as specified by the integer value passed as a parameter.
* moveToRow. Move the Catfish to the row specified by the integer value passed as a parameter.
Returns the row where the Catfish is moved as an integer.
* moveToColumn. Move the Catfish to the column specified by the integer value passed as a parameter.
Returns the column where the Catfish is moved as an integer.
* getDirection. Check the direction in which the Catfish is facing. Returns a String.
* lookForFoodInNeighboardhood. Return a neighboring algae that is food.
* isHungry. Check if the current energy level of the Catfish is less than twice the amount needed for survival.
Returns a boolean.
***** new behaviors inserted below ************************************************************************
* swim. Move the catfish to an adjacent cell: update the row and column of the Catfish. It could be a determined cell
that is provided from the food search, otherwise it can be a random adjacent cell within lake boundaries.
Returns nothing
* eat. Returns the energy gained as an integer when eating the algae specified by the algae object passed as a parameter.
***** bonus behaviors inserted below ************************************************************************
* increasesMinEnergy. A method that, for each time block, increments the value of the instance variable attribute for the minimum amount of energy required by a Catfish to stay alive in a time block.
* increasesMaxEnergy. A method that, for each time block, increments the value of the instance variable attribute for the maximum amount of energy that can be stored ("carried') by a Catfish
2) Instance attributes:
* row. Row identifying the location represented as an integer
* column. Column identifying the location represented as an integer
* deadOrAlive. Living status represented as a String
* energy. Current energy level represented as a String
* age. Age represented as an integer
* simulation. Simulation to which the Catfish belongs
* minEnergy. Minimum energy needed to survive
* maxEnergy. Maximum energy that can be carried
* direction. The direction in which the Catfish is facing represented as a String
Constant instance attributes:
* name. Unique name represented as a String
3) Class Attributes:
* nCatfishCreated. Number of Catfish created so far represented as an integer
Constant Class Attributes:
* ALIVE. Status of Catfish that is alive represented as a String
* DEAD. Status of Catfish that is dead represented as a String
* SPECIES. Species of Catfish represented as a String
* BABY_MAX_ENERGY. Maximum energy that can be stored, represented as an integer
* BABY_MIN_ENERGY. Minimum energy needed to stay alive, represented as an integer
* RIGHT. Indicate the direction catfish is facing represented as String
* LEFT. Indicate the direction catfish is facing represented as String
* UP. Indicate the direction catfish is facing represented as String
* DOWN. Indicate the direction catfish is facing represented as String
***** new constant class attributes inserted below ************************************************************
* ENERGY_TO_LOOK_FOR_FOOD. Energy needed to look for food represented as integer
* ENERGY_TO_SWIM. Energy needed to swim represented as integer
* ENERGY_TO_EAT. Energy needed to swim represented as integer
* AMOUNT_OF_FOOD_IN_FULL_MEAL. Amount of food(energy) that a Catfish can eat in a full meal representated as integer
* INCREMENT_FOR_MIN_ENERGY. The amount by which the minimun energy a Catfish requires to stay alive will be incremented by for each time block, represented as integer.
* INCREMENT_FOR_MAX_ENERGY. The amount by which the maximum energy that a Catfish can store by will be incremented by for each time block, represented as an integer.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -