|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Parser
public class Parser
This class is used to get user input from the keyboard. For full details of the Parser class, see Lab 9. This class does not have a constructor, and all it's methods are static. Thus, they are called by Parser.parse(), for example.
Field Summary | |
---|---|
static int |
ATTACK
The value that parse() returns if the user
enters 'attack' to attack the creature in the room. |
static int |
DO_NOT_UNDERSTAND
The value that parse() returns if it did not
understand what the user entered. |
static int |
EAST
The value that parse() returns if the user
enters 'east' to move to the room to the east. |
static int |
GET
The value that parse() returns if the user
enters 'get' to pick up the weapon in the room. |
static int |
LOOK
The value that parse() returns if the user
enters 'look' to see the room description again. |
static int |
NORTH
The value that parse() returns if the user
enters 'north' to move to the room to the north. |
static int |
QUIT
The value that parse() returns if the user
enters 'quit' to quit the game. |
static int |
SOUTH
The value that parse() returns if the user
enters 'south' to move to the room to the south. |
static int |
WEST
The value that parse() returns if the user
enters 'west' to move to the room to the west. |
Method Summary | |
---|---|
static boolean |
askYesNoQuestion(java.lang.String prompt)
This method asks the question passed as a parameter, and keeps asking it until a yes or no answer is obtained. |
static int |
parse()
This method reads in the user's input from the keyboard, and returns a value corresponding to what the user entered. |
static void |
printCommands()
This method prints the available command to the screen. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NORTH
parse()
returns if the user
enters 'north' to move to the room to the north.
public static final int EAST
parse()
returns if the user
enters 'east' to move to the room to the east.
public static final int SOUTH
parse()
returns if the user
enters 'south' to move to the room to the south.
public static final int WEST
parse()
returns if the user
enters 'west' to move to the room to the west.
public static final int ATTACK
parse()
returns if the user
enters 'attack' to attack the creature in the room.
public static final int LOOK
parse()
returns if the user
enters 'look' to see the room description again.
public static final int GET
parse()
returns if the user
enters 'get' to pick up the weapon in the room.
public static final int QUIT
parse()
returns if the user
enters 'quit' to quit the game.
public static final int DO_NOT_UNDERSTAND
parse()
returns if it did not
understand what the user entered.
Method Detail |
---|
public static void printCommands()
public static int parse()
ATTACK
. The values returned are the fields
listed above.
public static boolean askYesNoQuestion(java.lang.String prompt)
prompt
- The question to ask.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |