Package com.bdtripp.hauntedhouse.model
Enum Class CommandWord
- All Implemented Interfaces:
Serializable,Comparable<CommandWord>,Constable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionReturn to the previous room.Charge an item.Drop an item.Eat an item.Fire an item.Give an item to a character.Move to another room.Display help information.Show the player's inventory.Look around the current room.Quit the game.Show the player's statistics.Pick up an item.Talk to a character.Represents an unrecognized or invalid command. -
Method Summary
Modifier and TypeMethodDescriptionstatic CommandWordfromString(String word) Converts a string into a CommandWord if it is a valid commandstatic StringGet a list of all valid commandsstatic booleanChecks whether a given string is a valid command word.static CommandWordReturns the enum constant of this class with the specified name.static CommandWord[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
GO
Move to another room. -
QUIT
Quit the game. -
HELP
Display help information. -
LOOK
Look around the current room. -
EAT
Eat an item. -
BACK
Return to the previous room. -
TAKE
Pick up an item. -
DROP
Drop an item. -
ITEMS
Show the player's inventory. -
STATS
Show the player's statistics. -
CHARGE
Charge an item. -
FIRE
Fire an item. -
TALK
Talk to a character. -
GIVE
Give an item to a character. -
UNKNOWN
Represents an unrecognized or invalid command.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
isCommand
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
Get a list of all valid commands- Returns:
- a list of all valid commands separated by spaces
-
fromString
Converts a string into a CommandWord if it is a valid command- Parameters:
word- a string to convert to a CommandWord- Returns:
- the CommandWord
-