Constructor and Description |
---|
Trader(Brokerage brokerage,
java.lang.String name,
java.lang.String pswd)
Constructs a new trader, affiliated with a given brockerage, with a given
screen name and password.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Trader other)
Compares this trader to another by comparing their
screen names case blind.
|
boolean |
equals(java.lang.Object other)
Indicates whether some other trader is "equal to" this one, based on
comparing their screen names case blind.
|
java.lang.String |
getName()
Returns the screen name for this trader.
|
java.lang.String |
getPassword()
Returns the password for this trader.
|
void |
getQuote(java.lang.String symbol)
Requests a quote for a given stock symbol from the brokerage by calling
brokerage's
getQuote . |
boolean |
hasMessages()
Returns true if this trader has any messages in its mailbox.
|
void |
openWindow()
Creates a new
TraderWindow for this trader and saves
a reference to it in myWindow . |
void |
placeOrder(TradeOrder order)
Places a given order with the brokerage by calling
brokerage's
placeOrder . |
void |
quit()
Logs out this trader.
|
void |
receiveMessage(java.lang.String msg)
Adds
msg to this trader's mailbox and displays all messages. |
public Trader(Brokerage brokerage, java.lang.String name, java.lang.String pswd)
brokerage
- the brokerage for this trader.name
- user name.pswd
- password.public java.lang.String getName()
public java.lang.String getPassword()
public int compareTo(Trader other)
compareTo
in interface java.lang.Comparable<Trader>
other
- the reference to a trader with which to compare.other
.public boolean equals(java.lang.Object other)
ClassCastException
if other is not
an instance of Trader
.equals
in class java.lang.Object
other
- the reference to an object with which to compare.other
's;
false otherwise.public void openWindow()
TraderWindow
for this trader and saves
a reference to it in myWindow
.
Removes and displays all the messages, if any, from this trader's mailbox
by calling myWindow.show(msg)
for each message.public boolean hasMessages()
public void receiveMessage(java.lang.String msg)
msg
to this trader's mailbox and displays all messages.
If this trader is logged in (myWindow
is not null
)
removes and shows all the messages in the mailbox by calling
myWindow.showMessage(msg)
for each msg
in the mailbox.msg
- a message to be added to this trader's mailbox.public void getQuote(java.lang.String symbol)
getQuote
.symbol
- a stock symbol for which a quote is requested.public void placeOrder(TradeOrder order)
placeOrder
.order
- a trading order to be placed.public void quit()
brokerage
's logout
for this trader. Sets myWindow
to null
(this method is called from a TraderWindow
's window listener
when the "close window" button is clicked).