import java.util.Calendar;
import java.util.GregorianCalendar;


/**
 * An abstract SecurityQuotation (extended by StockQuotation, 
 * FutureQuotation, etc...).
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public abstract class SecurityQuotation
{
    protected GregorianCalendar   date;
    protected double              open, high, low, close;
    protected int                 volume;
    

    /**
     * Explicit Value Constructor.
     *
     * @param date      The date of the entry
     * @param open      The opening price
     * @param high      The high price
     * @param low       The low price
     * @param close     The closing price
     * @param volume    The volume traded
     */
    protected SecurityQuotation(GregorianCalendar date, 
                                double open,double high,double low,double close,
                                int volume)
    {
       this.date = date;
       this.open = open;
       this.high = high;
       this.low = low;
       this.close = close;
       this.volume = volume;
    }
    
    /**
     * Return the closing price.
     *
     * @return    The closing price
     */
    public double getClose()
    {
       return close;
    }

    /**
     * Return the date.
     *
     * @return    The date of this quotation
     */
    public GregorianCalendar getDate()
    {
       return date;
    }

    /**
     * Return the high price.
     *
     * @return    The high price
     */
    public double getHigh()
    {
       return high;
    }

    /**
     * Return the low price
     *
     * @return    The low price
     */
    public double getLow()
    {
       return low;
    }

    /**
     * Return the opening price.
     *
     * @return    The opening price
     */
    public double getOpen()
    {
       return open;
    }

    /**
     * Return the ticker symbol.
     */
    public abstract String getSymbol();
        

    /**
     * Returns the volume.
     *
     * @return    The volume
     */
    public int getVolume()
    {
       return volume;
    }

    /**
     * Return a String representation.
     *
     * @return   The String representation
     */
    public String toString()
    {
        return getSymbol() + "\t" +
            (date.get(Calendar.MONTH)+ 1) + "/" +
            date.get(Calendar.DAY_OF_MONTH) + "/" +
            date.get(Calendar.YEAR) +
            "\tO: " + open + "\tH: " + high +
            "\tL: " + low + "\tC: " + close + 
            "\tV: " + volume;
    }
}
