import java.util.*;
import java.io.*;

public class Timetable
{
    public static String SEPARATOR = ",";
    public static String OUT_OF_SERVICE = "x";

    public Timetable (String fileName, boolean debug)
    {
        _earliestDeparture = 0;
        _buses = new Vector<Bus>();
        _debug = debug;

        loadData(fileName);
    }

    private void loadData (String inputFile)
    {
        /*
         * Open the data file and read it in.
         */

        BufferedReader reader = null;

        try
        {
            reader = new BufferedReader(new FileReader(inputFile));
            String line = null;

            while ((line = reader.readLine()) != null)
            {
                if (_earliestDeparture == 0)
                {
                    _earliestDeparture = Integer.parseInt(line);

                    if (_debug)
                        System.out.println("Earliest departure time: "+_earliestDeparture+"\n");
                }
                else
                {
                    String[] busData = line.split(SEPARATOR);

                    for (int i = 0; i < busData.length; i++)
                    {
                        if (OUT_OF_SERVICE.equals(busData[i]))
                        {
                            if (_debug)
                                System.out.println("Loaded out of service bus.");
                        }
                        else
                        {
                            Bus bs = new Bus(Integer.parseInt(busData[i]), _earliestDeparture);

                            if (_debug)
                                System.out.println("Loaded "+bs);

                            _buses.add(bs);
                        }
                    }
                }
            }
        }
        catch (Throwable ex)
        {
            ex.printStackTrace();
        }
        finally
        {
            try
            {
                reader.close();
            }
            catch (Throwable ex)
            {
            }
        }

        _earliestDeparture = _buses.elementAt(0).nextDeparture();

        for (int i = 0; i < _buses.size(); i++)
        {
            if (_buses.elementAt(i).nextDeparture() < _earliestDeparture)
                _earliestDeparture = _buses.elementAt(i).nextDeparture();
        }
    }

    private int _earliestDeparture;
    private Vector<Bus> _buses;
    private boolean _debug;
}
@@ -327,32 +327,564 @@
 leName);%0A    %7D%0A%0A
+    public final int earliestDeparture ()%0A    %7B%0A        return _earliestDeparture;%0A    %7D%0A%0A    public final Bus busToCatch ()%0A    %7B%0A        int busDepartureTime = _buses.elementAt(0).nextDeparture();%0A        Bus bs = null;%0A%0A        for (int i = 0; i %3C _buses.size(); i++)%0A        %7B%0A            if (_buses.elementAt(i).nextDeparture() %3C busDepartureTime)%0A            %7B%0A                busDepartureTime = _buses.elementAt(i).nextDeparture();%0A                bs = _buses.elementAt(i);%0A            %7D%0A        %7D%0A%0A        return bs;%0A    %7D%0A%0A
     private void
@@ -2569,292 +2569,8 @@
    %7D
-%0A%0A        _earliestDeparture = _buses.elementAt(0).nextDeparture();%0A%0A        for (int i = 0; i %3C _buses.size(); i++)%0A        %7B%0A            if (_buses.elementAt(i).nextDeparture() %3C _earliestDeparture)%0A                _earliestDeparture = _buses.elementAt(i).nextDeparture();%0A        %7D
 %0A   

Update Timetable.java