Class MonsterDatabase

java.lang.Object
MonsterDatabase
All Implemented Interfaces:
Iterable<Monster>

public class MonsterDatabase extends Object implements Iterable<Monster>
Database of available monster types (singleton pattern).
Since:
2014-07-18
  • Field Details

    • MONSTER_FILE_DEFAULT

      static final String MONSTER_FILE_DEFAULT
      Default file with monster information.
      See Also:
    • monsterFile

      static String monsterFile
      Name of file with monster information.
    • instance

      static MonsterDatabase instance
      The singleton class instance.
    • monsterList

      List<Monster> monsterList
      List of Monster records.
  • Constructor Details

    • MonsterDatabase

      protected MonsterDatabase() throws IOException
      Constructor (read from dedicated file).
      Throws:
      IOException
  • Method Details

    • getInstance

      public static MonsterDatabase getInstance()
      Access the singleton class instance.
    • iterator

      public Iterator<Monster> iterator()
      Implement the iterable interface.
      Specified by:
      iterator in interface Iterable<Monster>
    • getByRace

      public Monster getByRace(String race)
      Get a monster by matching its race.
    • getRandom

      public Monster getRandom()
      Get a random monster from the database.
    • setDatabaseFilename

      public static void setDatabaseFilename(String filename)
      Set an alternate monster database filename.
    • main

      public static void main(String[] args)
      Main test method. Prints stat blocks for all monsters in database. Takes alternate database file from command line.