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

    Fields 
    Modifier and Type Field Description
    protected boolean flying  
    protected java.lang.Integer health  
    protected java.lang.String name  
    protected Position position  
    protected java.lang.Integer price  
    protected java.lang.Integer speed  
    protected java.awt.image.BufferedImage troopImage  
  • Constructor Summary

    Constructors 
    Constructor Description
    Troop()  
  • Method Summary

    Modifier and Type Method Description
    Region getCurrentRegion()  
    java.lang.Integer getHealth()  
    java.lang.String getName()  
    Position getPosition()  
    java.lang.Integer getPrice()  
    java.lang.Integer getSpeed()  
    java.awt.image.BufferedImage getTroopImage()  
    java.lang.Boolean inGoal()
    inGoal()
    boolean isFlying()
    isFlying()
    void move()
    move() - Moves the troop towards the location given.
    void setCurrentRegion​(Region r)  
    void setHealth​(java.lang.Integer health)  
    void setInGoal​(java.lang.Boolean b)
    setInGoal()
    void setPosition​(Position position)  
    void setTroopImage​(java.awt.image.BufferedImage img)  
    void subtractHealth​(java.lang.Integer damage)
    subtractHealth() - Subtracts health from troop.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • health

      protected java.lang.Integer health
    • speed

      protected java.lang.Integer speed
    • flying

      protected boolean flying
    • position

      protected Position position
    • price

      protected java.lang.Integer price
    • name

      protected java.lang.String name
    • troopImage

      protected java.awt.image.BufferedImage troopImage
  • Constructor Details

  • Method Details

    • getHealth

      public java.lang.Integer getHealth()
    • getSpeed

      public java.lang.Integer getSpeed()
    • getPosition

      public Position getPosition()
    • getPrice

      public java.lang.Integer getPrice()
    • getName

      public java.lang.String getName()
    • getTroopImage

      public java.awt.image.BufferedImage getTroopImage()
    • getCurrentRegion

      public Region getCurrentRegion()
    • setHealth

      public void setHealth​(java.lang.Integer health)
    • setPosition

      public void setPosition​(Position position)
    • setTroopImage

      public void setTroopImage​(java.awt.image.BufferedImage img)
    • setCurrentRegion

      public void setCurrentRegion​(Region r)
    • 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.