import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;

/**
 * Finds and displays departure-times of trains
 *
 * @version  1.0
 * @author   Prof. David Bernstein, James Madison University
 */
public class DTFDriver
{

    /**
     * The entry-point of the application
     *
     * @param args   The command line arguments (train, station)
     */
    public static void main(String[] args) throws Exception
    {
	DepartureTimeFinder  finder;
	File                 amtrak;
	SAXParser            parser;
	SAXParserFactory     factory;
	String               time;


	amtrak  = new File("amtrak.xml");
	factory = SAXParserFactory.newInstance();
	parser  = factory.newSAXParser();
	finder  = new DepartureTimeFinder(args[0], args[1]);
	
	parser.parse(amtrak, finder);
	time = finder.getDepartureTime();

	if (time == null) System.out.println("Sorry!");
	else              System.out.println("Train "+args[0]+
					     " departs "+args[1]+
					     " at "+time);

    }


}
