import java.io.*;
import java.util.*;

/**
 * An abstract class for reading SecurityQuotation information
 * from a BufferedReader
 *
 *
 * @version 1.0
 * @author  Prof. David Bernstein, James Madison University
 *
 */
 public abstract class SecurityReader
 {
    protected BufferedReader   reader;


    /**
     * Initialize attributes (called by the constructor of a
     * a derived class)
     */
     public SecurityReader(BufferedReader reader)
     {
			this.reader = reader;
     }


    /**
     * Read an entry
     *
     * @return The next SecurityQuotation
     */
     public abstract SecurityQuotation readSecurity() throws IOException,
                                                   NoSuchElementException,
                                                   NumberFormatException;



    /**
     * Read all (until the BufferedReader returns null) SecurityQuotation 
     * objects and prints them
     *
     * Note: This method uses the readSecurity() method of the derived
     * class.
     */
     public void readAndPrintSecurities() throws IOException,
													NoSuchElementException,
													NumberFormatException
     {
			SecurityQuotation     quote;

			while ( (quote=readSecurity()) != null) 
			{
			    System.out.println(quote);
			}
    }
} // end SecurityReader
