public class StockExchange
extends java.lang.Object
StockExchange
keeps
a HashMap
of stocks, keyed by a stock symbol. It has methods to
list a new stock, request a quote for a given stock symbol, and
to place a specified trade order.Constructor and Description |
---|
StockExchange()
Constructs a new stock exchange object.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getQuote(java.lang.String symbol)
Returns a quote for a given stock.
|
void |
listStock(java.lang.String symbol,
java.lang.String name,
double price)
Adds a new stock with given parameters to the listed stocks.
|
void |
placeOrder(TradeOrder order)
Places a trade order by calling
stock.placeOrder
for the stock specified by the stock symbol in the trade order. |
public StockExchange()
HashMap
).public void listStock(java.lang.String symbol, java.lang.String name, double price)
symbol
- stock symbol.name
- full company name.price
- opening stock price.public java.lang.String getQuote(java.lang.String symbol)
symbol
- stock symbol.public void placeOrder(TradeOrder order)
stock.placeOrder
for the stock specified by the stock symbol in the trade order.order
- a trading order to be placed with this stock exchange.