/**
  * Print out some details about a segment. This is far from all the available information.
  *
  * @param segment the segment to be displayed
  * @param fmt the formatter to use to display the data
  */
 public void printLeg(AirSegment segment, Formatter fmt) {
   Date dep = Helper.dateFromISO8601(segment.getDepartureTime());
   fmt.format(
       "AIR Departing from %3s to %3s on %Tc\n",
       segment.getOrigin(), segment.getDestination(), dep);
   fmt.format(
       "         Flight [%2s]#%4s  Flight time: %s minutes\n",
       segment.getCarrier(), segment.getFlightNumber(), segment.getFlightTime());
   fmt.format(
       "                           Arrive %Tc\n",
       Helper.dateFromISO8601(segment.getArrivalTime()));
 }
  public void printRail(Formatter fmt) {
    // print out the segments first
    List<RailJourneyRef> journeyKeys = railSolution.getRailJourneyRef();
    for (Iterator<RailJourneyRef> iterator = journeyKeys.iterator(); iterator.hasNext(); ) {
      RailJourneyRef journeyRef = (RailJourneyRef) iterator.next();
      // looking the journey by its key
      RailJourney j = railJourneys.getByRef(journeyRef);
      printJourney(j, fmt);
      if (j.getDestination().equals(roundTripTurnaround)) {
        fmt.format("%s", "\n\n");
      }
    }

    fmt.format("Total Price %s", railSolution.getTotalPrice());
  }
  public void printAir(Formatter fmt) {
    // print out the segments first
    List<AirSegmentRef> segKeys = airSolution.getAirSegmentRef();
    for (Iterator<AirSegmentRef> iterator = segKeys.iterator(); iterator.hasNext(); ) {
      AirSegmentRef airSegmentRef = (AirSegmentRef) iterator.next();
      // looking the leg by its key
      AirSegment leg = airSegs.getByRef(airSegmentRef);
      printLeg(leg, fmt);
      if (leg.getDestination().equals(roundTripTurnaround)) {
        fmt.format("%s", "\n\n");
      }
    }

    fmt.format(
        "Base Price: %s   Total Price %s", airSolution.getBasePrice(), airSolution.getTotalPrice());
  }
  public void printJourney(RailJourney journey, Formatter fmt) {
    Date dep = Helper.dateFromISO8601(journey.getDepartureTime());

    fmt.format(
        "RAIL (%s) From %s to %s on %Tc\n",
        journey.getJourneyDirection(),
        journey.getOriginStationName(),
        journey.getDestinationStationName(),
        dep);

    List<RailSegmentRef> onThisJourney = journey.getRailSegmentRef();
    for (Iterator<RailSegmentRef> rsIter = onThisJourney.iterator(); rsIter.hasNext(); ) {
      RailSegment railSegment = railSegments.get(rsIter.next().getKey());
      if (railSegment.getOperatingCompany() == null) {
        fmt.format("         METRO");
      } else {
        fmt.format(
            "         %s[%2s] Train #%4s  ",
            railSegment.getOperatingCompany().getName(),
            railSegment.getOperatingCompany().getCode(),
            railSegment.getTrainNumber());
      }
      fmt.format(
          " --- From "
              + railSegment.getOriginStationName()
              + " to "
              + railSegment.getDestinationStationName());
      if (railSegment.getTravelTime() != null) {
        fmt.format("Travel time: %s minutes\n", railSegment.getTravelTime());
      } else {
        fmt.format("\n");
      }
    }
    fmt.format(
        "                           Arrive %Tc\n",
        Helper.dateFromISO8601(journey.getArrivalTime()));
  }