import java.util.*;

/**
 * A future's contract quotation (i.e., open, high, low, close,
 * volume, and open interest)
 *
 *
 * @version 1.0
 * @author  Prof. David Bernstein, James Madison University
 *
 */
public class FutureQuotation extends SecurityQuotation
{
    protected int              openInterest;
    protected TickerSymbol     symbol;



    /**
     * Default constructor
     */
    public FutureQuotation()
    {
	symbol = null;
    }




    /**
     * Construct a new FutureQuotation
     *
     * @param symbol    The TickerSymbol for the commodity
     * @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 FutureQuotation(TickerSymbol symbol, GregorianCalendar date, 
			   double open,double high,double low,double close,
                           int volume, int openInterest)
    {
	super(date, open, high, low, close, volume);
	this.openInterest = openInterest;

	this.symbol = symbol;
    }



    /**
     * Return the symbol for this security
     *
     * @param symbol     The ticker symbol for this stock
     */
    public TickerSymbol getSymbol()
    {
        return symbol;
    }



    /**
     * Parse a String representation of a FutureQuotation into 
     * its components and construct a FutureQuotation from them.
     *
     * @param s    The String representation
     */
    public static FutureQuotation parseFutureQuotation(TickerSymbol symbol,
						       String s) 
                                  throws NoSuchElementException,
                                         NumberFormatException
    {
	FutureQuotation         fq;
	String                  token;
	StringTokenizer         tokenizer;


	fq = new FutureQuotation();
	fq.symbol = symbol;

	tokenizer = fq.parseSecurityQuotation(s);
	
	token = tokenizer.nextToken();
	fq.openInterest = Integer.parseInt(token);


	tokenizer = null;
	return fq;
    }



    /**
     * Return a String representation of this FutureQuotation
     *
     * @return   The String representation
     */
    public String toString()
    {
	return (super.toString()+"\tOI: " + openInterest);
    }

}
