Package pvzclone.model.impl
Class PlantImpl
java.lang.Object
pvzclone.model.impl.PlantImpl
- All Implemented Interfaces:
ActiveEntities
,Entities
,Plant
class that implements Plant interface.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
double
long
int
Returns the cost of the plant.double
boolean
isAlive()
void
receiveDamage
(double damageReceived) This method decreases Health Points.void
setLastTimeAttack
(long lastTimeAttack) Sets the respective field.
-
Field Details
-
PLANT_COST
public static final int PLANT_COSTis the cost of the plant.- See Also:
-
-
Constructor Details
-
PlantImpl
public PlantImpl(double damage, double remainingLife, String entityName, Pair<Integer, Integer> position, long cooldown) - Parameters:
damage
- is the damage that the plant doremainingLife
- is the remaining life of the plantentityName
- is the name of the entity, for the plant is "plant"position
- is the position of the plantcooldown
- is the time between two attack of the plant
-
-
Method Details
-
getDamage
public double getDamage()- Specified by:
getDamage
in interfaceActiveEntities
- Returns:
- entity's Attack Damage.
-
getRemainingLife
public double getRemainingLife()- Specified by:
getRemainingLife
in interfaceActiveEntities
- Returns:
- entity's Health Points.
-
getPosition
- Specified by:
getPosition
in interfaceEntities
- Returns:
- position of the entity.
-
isAlive
public boolean isAlive() -
getEntityName
- Specified by:
getEntityName
in interfaceEntities
- Returns:
- name of the entity.
-
receiveDamage
public void receiveDamage(double damageReceived) Description copied from interface:ActiveEntities
This method decreases Health Points.- Specified by:
receiveDamage
in interfaceActiveEntities
- Parameters:
damageReceived
- Attack Damage that entity has received.
-
getCooldown
public long getCooldown()- Specified by:
getCooldown
in interfaceActiveEntities
- Returns:
- time needed to start and finish an attack.
-
setLastTimeAttack
public void setLastTimeAttack(long lastTimeAttack) Description copied from interface:ActiveEntities
Sets the respective field.- Specified by:
setLastTimeAttack
in interfaceActiveEntities
- Parameters:
lastTimeAttack
- time since the last attack.
-
getLastTimeAttack
public long getLastTimeAttack()- Specified by:
getLastTimeAttack
in interfaceActiveEntities
- Returns:
- time since the last attack.
-
getPlantCost
public int getPlantCost()Description copied from interface:Plant
Returns the cost of the plant.- Specified by:
getPlantCost
in interfacePlant
- Returns:
- cost to buy the plant.
-