java.lang.Object
edu.ntnu.idatt2001.carljgu.battle.units.Unit
edu.ntnu.idatt2001.carljgu.battle.units.specialized.InfantryUnit

public class InfantryUnit extends Unit
Class InfantryUnit that inherits from Unit. InfantryUnit objects implements methods from the superclass.
Version:
1.4 01.05.2022
Author:
Carl Gützkow
  • Field Details

  • Constructor Details

    • InfantryUnit

      public InfantryUnit(String name, int health, int attack, int armor)
      Instantiates a new Infantry unit. Uses the constructor of its superclass Unit
      Parameters:
      name - String - a short name of the unit that can't be left with whitespace or empty.
      health - int - HP - amount of health unit has. If it hits zero or more, the unit is dead.
      attack - int - damage done, excluding attack bonus, on an enemy unit.
      armor - int - damage resisted, excluding resist bonus, from an enemy unit.
    • InfantryUnit

      public InfantryUnit(String name, int health)
      Instantiates a new Infantry unit with a simplified constructor. Attack is set to 15 and health is set to 10 Uses the constructor over since it instantiates other variables
      Parameters:
      name - String - a short name of the unit that can't be left with whitespace or empty.
      health - int - HP - amount of health unit has. If it hits zero or more, the unit is dead.
  • Method Details

    • getAttackBonus

      public int getAttackBonus(Terrain terrain)
      Overrides the abstract method getAttackBonus from Unit. The attack bonus is increased if the terrain is forest.
      Specified by:
      getAttackBonus in class Unit
      Parameters:
      terrain - Terrain - the terrain where the attack occurs.
      Returns:
      attackBonus - int - value of the attack bonus used when calculating an enemy unit's health in an attack.
    • getResistBonus

      public int getResistBonus(Terrain terrain)
      Overrides the abstract method getResistBonus from Unit. The resistance bonus is increased if the terrain is forest.
      Specified by:
      getResistBonus in class Unit
      Parameters:
      terrain - Terrain - the terrain where the attack occurs.
      Returns:
      resistBonus - int - value of the resist bonus used when calculating this object's health in an attack.