Class Hero

java.lang.Object
characters.DungeonCharacter
characters.heroes.Hero
All Implemented Interfaces:
java.lang.Comparable<java.lang.Object>
Direct Known Subclasses:
Sorceress, Thief, Warrior

public abstract class Hero
extends DungeonCharacter
Abstract base class for a hierarchy of heroes. It is derived from DungeonCharacter. A Hero has battle choices: regular attack and a special skill which is defined by the classes derived from Hero.
  • Field Details

    • chanceToBlock

      protected double chanceToBlock
    • numTurns

      protected int numTurns
  • Constructor Details

    • Hero

      protected Hero​(java.lang.String name, int hitPoints, int attackSpeed, double chanceToHit, int damageMin, int damageMax, double chanceToBlock)
      Call the base constructor and get the name of hero from the user.
      Parameters:
      name - Name of character.
      hitPoints - Points of damage a character can take before killed.
      attackSpeed - How fast the character can attack.
      chanceToHit - Chance an attack will strike the opponent.
      damageMin - Minimum amount of damage a character can inflict.
      damageMax - Maximum amount of damage a character can inflict.
      chanceToBlock - The chance to block an opponents attack.
  • Method Details

    • readName

      public void readName()
      Obtains the name for the hero specified by the user.
    • subtractHitPoints

      public void subtractHitPoints​(int hitPoints)
      Check if the hero blocked the attack, and if so a message is displayed, otherwise the base version of this method is invoked to perform the subtraction operation.
      Overrides:
      subtractHitPoints in class DungeonCharacter
      Parameters:
      hitPoints - The number of hit points to subtract.
    • numOfTurns

      public void numOfTurns​(DungeonCharacter opponent)