Enum Class CommandWord

java.lang.Object
java.lang.Enum<CommandWord>
com.bdtripp.hauntedhouse.model.CommandWord
All Implemented Interfaces:
Serializable, Comparable<CommandWord>, Constable

public enum CommandWord extends Enum<CommandWord>
An enumeration of all valid commands. Each constant represents a command that the game engine can execute. The UNKNOWN value is used when player input does not match any defined command.
Author:
Brian Tripp
  • Enum Constant Details

    • GO

      public static final CommandWord GO
      Move to another room.
    • QUIT

      public static final CommandWord QUIT
      Quit the game.
    • HELP

      public static final CommandWord HELP
      Display help information.
    • LOOK

      public static final CommandWord LOOK
      Look around the current room.
    • EAT

      public static final CommandWord EAT
      Eat an item.
    • BACK

      public static final CommandWord BACK
      Return to the previous room.
    • TAKE

      public static final CommandWord TAKE
      Pick up an item.
    • DROP

      public static final CommandWord DROP
      Drop an item.
    • ITEMS

      public static final CommandWord ITEMS
      Show the player's inventory.
    • STATS

      public static final CommandWord STATS
      Show the player's statistics.
    • CHARGE

      public static final CommandWord CHARGE
      Charge an item.
    • FIRE

      public static final CommandWord FIRE
      Fire an item.
    • TALK

      public static final CommandWord TALK
      Talk to a character.
    • GIVE

      public static final CommandWord GIVE
      Give an item to a character.
    • UNKNOWN

      public static final CommandWord UNKNOWN
      Represents an unrecognized or invalid command.
  • Method Details

    • values

      public static CommandWord[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CommandWord valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isCommand

      public static boolean isCommand(String aString)
      Checks whether a given string is a valid command word.
      Parameters:
      aString - the string to check
      Returns:
      true if a given string is a valid command, false if it isn't.
    • getCommandList

      public static String getCommandList()
      Get a list of all valid commands
      Returns:
      a list of all valid commands separated by spaces
    • fromString

      public static CommandWord fromString(String word)
      Converts a string into a CommandWord if it is a valid command
      Parameters:
      word - a string to convert to a CommandWord
      Returns:
      the CommandWord