cs1705.adventure
Class Parser
java.lang.Object
cs1705.adventure.Parser
- public class Parser
- extends Object
This parser reads user input and tries to interpret it as an "Adventure"
command. Every time it is called it reads a line from the terminal and
tries to interpret the line as a two word command. It returns the command
as an object of class Command.
This class is part of the "World of Zuul" framework for writing
very simple text-based adventure games.
The parser has a set of known command words. It checks user input against
the known commands, and if the input is not one of the known commands, it
returns a command object that is marked as an unknown command.
- Version:
- 1.1 (December 2002)
- Author:
- Michael Kolling and David J. Barnes
Parser
public Parser()
commandWords
public CommandWords commandWords()
- Access the set of valid command words.
getCommand
public Command getCommand()
promptString
public String promptString()
- Get the prompt string printed before reading each command.
A subclass can override this method to change the prompt.
- Returns:
- the prompt used for user input