|
||||||||
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 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 see what is available to buy at the current market. |
static int |
BUY
The value that parse() returns if the user
enters 'buy' to buy cargo at the current market. |
static int |
DO_NOT_UNDERSTAND
The value that parse() returns if it did not
understand what the user entered. |
static int |
EXIT_MARKET
The value that parse() returns if the user
enters 'exit' to exit the market and return to the location. |
static int |
INVENTORY
The value that parse() returns if the user
enters 'inventory' to display his/her inventory. |
static int |
MARKET
The value that parse() returns if the user
enters 'market' to enter the market at teh current location. |
static int |
QUIT
The value that parse() returns if the user
enters 'quit' to quit the game. |
static int |
SELL
The value that parse() returns if the user
enters 'sell' sell cargo at the current market. |
private static java.util.Scanner |
stdin
The Scanner object that is used by the various Parser methods |
static int |
TRAVEL
The value that parse() returns if the user
enters 'travel' to travel to another location in the universe. |
static int |
WORLDMAP
The value that parse() returns if the user
enters 'worldmap' to print the map of the universe. |
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 Location |
getDestination()
This method asks the user to enter the name of the location to travel to, having indicated that he/she wants to travel to a new location |
static int |
getItemToTrade(Inventory inventory,
double marketCostFactor)
This method asks the user to enter the number corresponding to the items he/she wants to trade |
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 market.
public static final int TRAVEL
parse()
returns if the user
enters 'travel' to travel to another location in the universe.
public static final int MARKET
parse()
returns if the user
enters 'market' to enter the market at teh current location.
public static final int EXIT_MARKET
parse()
returns if the user
enters 'exit' to exit the market and return to the location.
public static final int WORLDMAP
parse()
returns if the user
enters 'worldmap' to print the map of the universe.
public static final int SELL
parse()
returns if the user
enters 'sell' sell cargo at the current market.
public static final int AVAILABLE
parse()
returns if the user
enters 'available' to see what is available to buy at the current market.
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 Location getDestination()
public static int getItemToTrade(Inventory inventory, double marketCostFactor)
inventory
- the inventory of the current market,marketCostFactor
- double value indicating the market cost factor
public static int parse()
TRAVEL
. The values returned are the fields
listed above.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |