|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Stock portfolio manager. Allows buy and sell actions on a portfolio of stock, and computes capital gains on sell actions.
Method Summary | |
boolean |
buy(java.lang.String stock,
java.util.Date date,
double shares,
double pricePerShare)
Add a block of stock to the portfolio. |
java.util.List |
getBlocksOwned()
Return a list of all the blocks of stock that are owned. |
double |
getSharesOwned(java.lang.String stock)
Tells the number of shares owned of a particular stock. |
double |
sell(java.lang.String stock,
java.util.Date saleDate,
double shares,
double pricePerShare)
"Sell" a block of a stock, in the process calculating the capital gain on the stock. |
java.lang.String |
toString()
Gives a compact summary of the information in the Portfolio. |
Method Detail |
public boolean buy(java.lang.String stock, java.util.Date date, double shares, double pricePerShare)
stock
- a non-null stockdate
- a non-null date/time. You may assume for now that each
block is at a later date/time than any previous block bought.shares
- a number of shares, must be > 0.pricePerShare
- price of each share, must be > 0.
java.lang.IllegalArgumentException
- if any argument value is invalid.public double sell(java.lang.String stock, java.util.Date saleDate, double shares, double pricePerShare)
stock
- non-null stock being sold; must be a stock currently owned.saleDate
- non-null date of the sale.shares
- number of shares being sold, must be >= 0.pricePerShare
- price of each share, must be >= 0.
java.lang.IllegalArgumentException
- if any parameter value is invalid, or
if the number of shares being sold is greater than the number of shares
of that stock currently owned.public double getSharesOwned(java.lang.String stock)
stock
- a non-null stock.
public java.util.List getBlocksOwned()
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |