import java.util.*;

/**
 * A stock quotation (i.e., open, high, low, close and  volume).
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 3.0
 */
public class StockQuotation extends SecurityQuotation
{
    protected String           symbol;

//[constructor
    /**
     * Default Constructor.
     *
     * Normally, the use of this constructor is followed immediately
     * by a call to fromString() to set the attributes.
     */
    protected StockQuotation()
    {
        super();
    }
//]constructor

    /**
     * Explicit Value Constructor.
     *
     * @param symbol    The ticker symbol of the stock
     * @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
     */
    public StockQuotation(String symbol, GregorianCalendar date, 
			  double open,double high,double low,double close,
                          int volume)
    {
	super(date, open, high, low, close, volume);
	this.symbol = symbol;
    }


//[createInstance    
    /**
     * Parse a String representation of a StockQuotation into 
     * its components and construct a StockQuotation from them.
     *
     * @param s         The String representation
     */
    public static StockQuotation createInstance(String s) 
                                 throws NoSuchElementException,
                                        NumberFormatException
    {
	StockQuotation sq;
	sq = new StockQuotation();
	sq.fromString(s);
	return sq;
    }
//]createInstance

    
//[fromString
    /**
     * Set the attributes of this StockQuotation based on
     * a String representation.
     *
     * @param symbol  The ticker symbol
     * @param s       The String representation
     * @return    The StringTokenizer in case it is needed by a derived class
     */
    public StringTokenizer fromString(String symbol, String s) 
        throws NoSuchElementException, NumberFormatException
    {
        StringTokenizer      tokenizer;

        this.symbol = symbol;
        tokenizer = super.fromString(s);

        return tokenizer;
    }
//]fromString

    /**
     * Return the ticker symbol (required by SecurityQuotation).
     *
     * @param symbol     The ticker symbol
     */
    public String getSymbol()
    {
        return symbol;
    }
}
