コード例 #1
0
 // Returns the train with the smallest time until arrival for the given stopname
 // NF
 public static Train getTrainAtStop(String stopName, Direction d, int offset) {
   LinkedList<Train> curTrains = new LinkedList<Train>();
   for (TrainLine line : (liveData ? liveLines : testLines)) {
     LinkedList<Train> trains = line.getTrains();
     for (int t = 0; t < trains.size(); t++) {
       Train curTrain = trains.get(t);
       if (curTrain.containsStop(stopName, offset) && curTrain.getTrainDirection() == d) {
         curTrains.add(curTrain);
       }
     }
   }
   return getEarliestTrain(curTrains, stopName);
 }
コード例 #2
0
 // Compares 2 trains and returns true if o1 has a greater time than o2
 // for the first prediction
 // NF
 public static boolean compare(Train o1, Train o2, String stopName) {
   return o1.getPredictionByName(stopName).getTime() > o2.getPredictionByName(stopName).getTime();
 }