Package model
Class Troop
java.lang.Object
model.Troop
- Direct Known Subclasses:
Aeroplane,Soldier,TeleporterTroop
public abstract class Troop
extends java.lang.Object
A troop is a unit that moves on a path from start to goal region. It has a specified amount of health, speed,
price and appearance.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Troop() -
Method Summary
Modifier and Type Method Description RegiongetCurrentRegion()java.lang.IntegergetHealth()java.lang.StringgetName()PositiongetPosition()java.lang.IntegergetPrice()java.lang.IntegergetSpeed()java.awt.image.BufferedImagegetTroopImage()java.lang.BooleaninGoal()inGoal()booleanisFlying()isFlying()voidmove()move() - Moves the troop towards the location given.voidsetCurrentRegion(Region r)voidsetHealth(java.lang.Integer health)voidsetInGoal(java.lang.Boolean b)setInGoal()voidsetPosition(Position position)voidsetTroopImage(java.awt.image.BufferedImage img)voidsubtractHealth(java.lang.Integer damage)subtractHealth() - Subtracts health from troop.
-
Field Details
-
Constructor Details
-
Troop
public Troop()
-
-
Method Details
-
getHealth
public java.lang.Integer getHealth() -
getSpeed
public java.lang.Integer getSpeed() -
getPosition
-
getPrice
public java.lang.Integer getPrice() -
getName
public java.lang.String getName() -
getTroopImage
public java.awt.image.BufferedImage getTroopImage() -
getCurrentRegion
-
setHealth
public void setHealth(java.lang.Integer health) -
setPosition
-
setTroopImage
public void setTroopImage(java.awt.image.BufferedImage img) -
setCurrentRegion
-
move
public void move()move() - Moves the troop towards the location given. Since the troop can only move in 4 directions, either the row or the column will be the same as the troop is currently in. Troops col/row is calculated by its x/y divided by 40. -
subtractHealth
public void subtractHealth(java.lang.Integer damage)subtractHealth() - Subtracts health from troop.- Parameters:
damage- - Damage to be subtracted.
-
inGoal
public java.lang.Boolean inGoal()inGoal()- Returns:
- True if troop has reached goal. False otherwise.
-
setInGoal
public void setInGoal(java.lang.Boolean b)setInGoal()- Parameters:
b- - True if troop is to be set in goal. False otherwise.
-
isFlying
public boolean isFlying()isFlying()- Returns:
- - True if the troop is a flying type. False otherwise.
-