/** * Returns a String representation of this Itinerary. * * @return This Itinerary as a String. */ @Override public String toString() { String str = new String(); for (Flight f : this.flights) { str += f.toString().substring(0, f.toString().lastIndexOf(",")) + "\n"; } // Make sure decimal is to 2 decimal place. DecimalFormat df = new DecimalFormat(".00"); str += df.format(this.getTotalCost()) + "\n"; str += String.format("%02d", this.getTotalTraveTime() / 60) + ":" + String.format("%02d", this.getTotalTraveTime() % 60); return str; }
/** * Returns the flights that leave on date from origin and travel to destination. * * @param date the date of departure * @param origin the place of departure * @param destination the place of arrival * @return String of flights that leave on date from origin and travel to destination */ public static String getFlights(String date, String origin, String destination) { String res = ""; ArrayList<Flight> flights = Client.getFlights(date, origin, destination); for (Flight flight : flights) { res += flight.toString() + "\n"; } res = res.trim(); return res; }
@Override public String toString() { return "Order{ " + "id=" + getId() + ", flight= " + flight.toString() + ", user ="******"}"; }