-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandWords.java
More file actions
39 lines (33 loc) · 906 Bytes
/
Copy pathCommandWords.java
File metadata and controls
39 lines (33 loc) · 906 Bytes
1
/* * This class holds an enumeration of all command words known to the game. * It is used to recognise commands as they are typed in. * */class CommandWords{ // a constant array that holds all valid command words private final String validCommands = "go quit help pick back look purse drop eat climb smash listen inspect conch scrape"; /** * Constructor - initialise the command words. */ public CommandWords() { // nothing to do at the moment... :( } /** * Check whether a given String is a valid command word. * Return true if it is, false if it isn't. **/ public boolean isCommand(String aString) { return validCommands.indexOf(aString) >= 0; } /** * Print all valid commands to System.out. */ public void showAll() { System.out.println(validCommands); }}