stockportfolio
Class AbsStockBlock

java.lang.Object
  extended bystockportfolio.AbsStockBlock
All Implemented Interfaces:
IStockBlock
Direct Known Subclasses:
StockBlock

public abstract class AbsStockBlock
extends java.lang.Object
implements IStockBlock

Information about a single block of stock. A "block" is defined by a number of shares of the same stock, purchased at the same time at the same price. You shouldn't need change this class, if you even use it.


Constructor Summary
AbsStockBlock(java.lang.String stock, java.util.Date date, double amount, double pricePerShare)
          Create a new block of stock.
 
Method Summary
 double getPricePerShare()
          Tells the price per share of shares in this block
 double getShares()
          Tells the number of shares in this block
 java.lang.String getStock()
          Tells the stock which was bought or sold.
 java.util.Date getTransactionDate()
          Tells the date the stock was purchased.
 java.lang.String toString()
          Give out a one-line summary of the block information.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbsStockBlock

public AbsStockBlock(java.lang.String stock,
                     java.util.Date date,
                     double amount,
                     double pricePerShare)
Create a new block of stock.

Parameters:
stock - a non-null string, which should be normalized and used as the stock name.
date - a non-null date, when the stock was purchased.
amount - the number of shares purchased (must be > 0).
pricePerShare - the price per shape (must be > 0).
Method Detail

getStock

public java.lang.String getStock()
Description copied from interface: IStockBlock
Tells the stock which was bought or sold. This should be the "normalized" stock name (see instructions).

Specified by:
getStock in interface IStockBlock
Returns:
a non-null String

getTransactionDate

public java.util.Date getTransactionDate()
Description copied from interface: IStockBlock
Tells the date the stock was purchased.

Specified by:
getTransactionDate in interface IStockBlock
Returns:
non-null date the stock was purchased

getShares

public double getShares()
Description copied from interface: IStockBlock
Tells the number of shares in this block

Specified by:
getShares in interface IStockBlock
Returns:
the number of shares, which is always >0.

getPricePerShare

public double getPricePerShare()
Description copied from interface: IStockBlock
Tells the price per share of shares in this block

Specified by:
getPricePerShare in interface IStockBlock
Returns:
the price per share, which must be >0

toString

public java.lang.String toString()
Give out a one-line summary of the block information.