|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstockportfolio.CommandReader
Simple text-based shell for stock portfolio manager. Class CommandReader is a text-based UI for the stock portfolio project. It implements a very simple shell with four commands:
BUY stockname quantity price date
SELL stockname quantity price date
REPORT
EXIT
All commands are case insensitive, but the stockname case sensitivity depends on the underlying portfolio implementation. quantity and price are doubles and date should be in mm/dd/yyyy format. Any unrecognized entry will print a usage string, so HELP and ? will both provide help (as will ASDFASDFASDF.) There are only three methods, setIn, setOut and run. This should be enough to provide simple console-based or file- based exercising of the portfolio functions. The main method simply hooks in to System.in, out to System.out and calls run.
Field Summary | |
static java.lang.String |
BUY_COMMAND
The BUY_COMMAND text for the CommandReader shell. |
static java.lang.String |
EXIT_COMMAND
The EXIT_COMMAND text for the CommandReader shell. |
static java.lang.String |
REPORT_COMMAND
The REPORT_COMMAND text for the CommandReader shell. |
static java.lang.String |
SELL_COMMAND
The SELL_COMMAND text for the CommandReader shell. |
static java.lang.String |
USAGE
The USAGE string for the CommandReader shell. |
Constructor Summary | |
CommandReader()
Default constructor sets in and out to System.in and System.out, respectively. |
Method Summary | |
static void |
main(java.lang.String[] args)
Simply sets up a command reader and runs it. |
void |
run()
The run method initiates the command processor |
void |
setIn(java.io.BufferedReader in)
setIn allows for redirection of input so that you can get commands from a file. |
void |
setOut(java.io.PrintWriter out)
setOut allows for redirection of output so that you can send results to a file (or anywhere else) |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String BUY_COMMAND
BUY_COMMAND
text for the CommandReader shell.
public static final java.lang.String SELL_COMMAND
SELL_COMMAND
text for the CommandReader shell.
public static final java.lang.String REPORT_COMMAND
REPORT_COMMAND
text for the CommandReader shell.
public static final java.lang.String EXIT_COMMAND
EXIT_COMMAND
text for the CommandReader shell.
public static final java.lang.String USAGE
USAGE
string for the CommandReader shell.
Constructor Detail |
public CommandReader()
Method Detail |
public void setIn(java.io.BufferedReader in)
in
- The BufferedReader that will be used for all
subsequent inputpublic void setOut(java.io.PrintWriter out)
out
- The PrintWriter that all subsequent output
will be sent to.public void run()
run
in interface java.lang.Runnable
Runnable.run()
public static void main(java.lang.String[] args)
args
- The first argument, if any, will be treated
as the name of a file from which to redirect input. The
second argument, if any, will be treated as the name of
a file to which output will be redirected.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |