|
|||||||||
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 commands as user input from the keyboard. For full 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 |
AVAILABLE
The value that parse() returns if the user
enters 'available' to check on the supplies available. |
static int |
BUY
The value that parse() returns if the user
enters 'buy' to buy cargo at the current depot. |
static int |
CHECK
The value that parse() returns if the user
enters 'CHECK' to check on the party's status. |
static int |
DEPOT
The value that parse() returns if the user
enters 'depot' to enter the depot at the current location. |
static int |
DO_NOT_UNDERSTAND
The value that parse() returns if it did not
understand what the user entered. |
static int |
EXIT_DEPOT
The value that parse() returns if the user
enters 'exit' to exit the depot and return to the location. |
static int |
FOOD
The value that parse() returns if the user
enters 'food' to change food rations. |
static int |
HUNT
The value that parse() returns if the user
enters 'hunt' to hunt/forage for food. |
static int |
INVENTORY
The value that parse() returns if the user
enters 'inventory' to display his/her inventory. |
static int |
MOVE
The value that parse() returns if the user
enters 'move' to move to another location on the map. |
static int |
PACE
The value that parse() returns if the user
enters 'pace' to change the pace. |
static int |
QUIT
The value that parse() returns if the user
enters 'quit' to quit the game. |
static int |
REST
The value that parse() returns if the user
enters 'rest' to rest. |
static int |
SELL
The value that parse() returns if the user
enters 'sell' sell items at the depot. |
private static java.util.Scanner |
stdin
The Scanner object that is used by the various Parser methods |
static int |
TRADE
The value that parse() returns if the user
enters 'TRADE' to trade. |
static int |
WORLDMAP
The value that parse() returns if the user
enters 'worldmap' to print the map. |
static int |
XCHEAT
The value that parse() returns if the user
enters 'xcheat' to enable cheat mode. |
Constructor Summary | |
---|---|
private |
Parser()
Making the constructor private prevents anybody from calling it (as we don't want to create objects of this class) |
Method Summary | |
---|---|
static int |
getInteger()
This method just reads in an integer, and returns that value. |
static int |
getItemToTrade(Inventory inventory,
double priceFactor)
This method asks the user to enter the number corresponding to the items he/she wants to trade |
static int |
getMoveDirection()
This method obtains a direction (n/s/e/w) to move, and returns the appropriate constant. |
static int |
parse()
This method reads in the user's input from the keyboard, and returns a value corresponding to what the user entered. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int QUIT
parse()
returns if the user
enters 'quit' to quit the game.
public static final int INVENTORY
parse()
returns if the user
enters 'inventory' to display his/her inventory.
public static final int BUY
parse()
returns if the user
enters 'buy' to buy cargo at the current depot.
public static final int MOVE
parse()
returns if the user
enters 'move' to move to another location on the map.
public static final int DEPOT
parse()
returns if the user
enters 'depot' to enter the depot at the current location.
public static final int EXIT_DEPOT
parse()
returns if the user
enters 'exit' to exit the depot and return to the location.
public static final int WORLDMAP
parse()
returns if the user
enters 'worldmap' to print the map.
public static final int SELL
parse()
returns if the user
enters 'sell' sell items at the depot.
public static final int XCHEAT
parse()
returns if the user
enters 'xcheat' to enable cheat mode.
public static final int FOOD
parse()
returns if the user
enters 'food' to change food rations.
public static final int HUNT
parse()
returns if the user
enters 'hunt' to hunt/forage for food.
public static final int REST
parse()
returns if the user
enters 'rest' to rest.
public static final int PACE
parse()
returns if the user
enters 'pace' to change the pace.
public static final int TRADE
parse()
returns if the user
enters 'TRADE' to trade.
public static final int CHECK
parse()
returns if the user
enters 'CHECK' to check on the party's status.
public static final int AVAILABLE
parse()
returns if the user
enters 'available' to check on the supplies available.
public static final int DO_NOT_UNDERSTAND
parse()
returns if it did not
understand what the user entered.
private static java.util.Scanner stdin
Constructor Detail |
---|
private Parser()
Method Detail |
---|
public static int getItemToTrade(Inventory inventory, double priceFactor)
inventory
- the inventory of the current market,priceFactor
- double value indicating the market cost factor
public static int getInteger()
public static int getMoveDirection()
Game.MOVE_NORTH
, Game.MOVE_SOUTH
,
Game.MOVE_EAST
, Game.MOVE_WEST
) representing the direction
to move to.public static int parse()
TRADE
. The values returned are the fields
listed above.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |