import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;

/**
 * Start of a class that stores UFO sighting data and allows for filtered searches.
 *   @author Dave Reed
 *   @version 11/2/15
 */
public class UFOlookup {
    private ArrayList<UFOsighting> sightings;

    /**
     * Constructor a UFOlookup object with data from the specified file.
     *   @param filename the name of the file containing the UFO sighting data
     */
    public UFOlookup(String filename) {
        this.sightings = new ArrayList<UFOsighting>();
        
	    try {
	        Scanner infile = new Scanner(new File(filename));
	        
    	    while (infile.hasNextLine()) {
    	        String date = infile.next();
    	        String state = infile.next();
    	        String city = infile.nextLine().trim();
    	        UFOsighting sight = new UFOsighting(date, state, city);
    	        this.sightings.add(sight);
    	    }
    	    infile.close();
    	}
    	catch (java.io.FileNotFoundException e) {
    	    System.out.println("No such file: " + filename);
    	}
    }

    /**
     * Accesses the total number of sightings stored.
     *   @return the number of sightings
     */
    public int numSightings() {
        return this.sightings.size();
    }
}
