student.adventure
Class CommandWords

java.lang.Object
  extended by student.adventure.CommandWords

public class CommandWords
extends java.lang.Object

This class holds a collection of all command words known to the game. It is used to recognize commands as they are typed in.

Version:
2.0 (December 2002)
Author:
Michael Kolling and David J. Barnes

Constructor Summary
CommandWords()
          Constructor - initialise the command words.
 
Method Summary
 void addCommand(java.lang.String word, Command command)
          Add (or replace) a command word.
 Command get(java.lang.String word)
          Given a command word, find and return the matching command object.
 void showAll()
          Print all valid commands to System.out.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandWords

public CommandWords()
Constructor - initialise the command words.

Method Detail

get

public Command get(java.lang.String word)
Given a command word, find and return the matching command object. Return null if there is no command with this name.

Parameters:
word - The word to look up
Returns:
The corresponding command, if any, or null, if the word is not in this Map

addCommand

public void addCommand(java.lang.String word,
                       Command command)
Add (or replace) a command word.

Parameters:
word - the word for this command
command - the associated command object implementing this command

showAll

public void showAll()
Print all valid commands to System.out.