Constructor and Description |
---|
Brokerage(StockExchange exchange)
Constructs new brokerage affiliated with a given stock exchange.
|
Modifier and Type | Method and Description |
---|---|
int |
addUser(java.lang.String name,
java.lang.String password)
Tries to register a new trader with a given screen name
and password.
|
void |
getQuote(java.lang.String symbol,
Trader trader)
Requests a quote for a given stock from the stock exachange
and passes it along to the trader
by calling trader's
receiveMessage method. |
int |
login(java.lang.String name,
java.lang.String password)
Tries to login a trader with a given screen name and password.
|
void |
logout(Trader trader)
Removes a specified trader from the set of logged-in traders.
|
void |
placeOrder(TradeOrder order)
Places an order at the stock exchange.
|
public Brokerage(StockExchange exchange)
exchange
- a stock exchange.public int addUser(java.lang.String name, java.lang.String password)
Trader
object
for this trader and adds this trader to the map of all traders
(using the screen name as the key).addUser
in interface Login
name
- the screen name of the trader.password
- the password for the trader.public int login(java.lang.String name, java.lang.String password)
openWindow()
method.
Adds the trader to the set of all logged-in traders.public void logout(Trader trader)
trader
- the trader that logs out.public void getQuote(java.lang.String symbol, Trader trader)
receiveMessage
method.symbol
- the stock symbol.trader
- the trader who requested a quote.public void placeOrder(TradeOrder order)
order
- an order to be placed at the stock exchange.