|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstudent.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. 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. |
java.lang.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 java.lang.String promptString()
public CommandWords commandWords()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |