|
CS 1705 Library | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcs1705.adventure.Parser
public class Parser
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.
| Constructor Summary | |
|---|---|
Parser()
Create a new Parser object connected to System.in. |
|
| Method Summary | |
|---|---|
CommandWords |
commandWords()
Access the set of valid command words. |
Command |
getCommand()
Get the next command from the input sequence. |
String |
promptString()
Get the prompt string printed before reading each command. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Parser()
System.in.
| Method Detail |
|---|
public Command getCommand()
commandWords(), and
pushing the second word into the resulting command (if there was
a second word). Any words on the line past the first two are
ignored.
public String promptString()
public CommandWords commandWords()
|
Last updated: Wed, Apr 1, 2009 12:29 AM EDT | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||