private static void getNewBooking() { Itinerary i = null; while (i == null) { System.out.print("Departure city: "); String depCity = input.next(); System.out.print("Destination city: "); String destCity = input.next(); i = service.getItinerary(depCity, destCity); if (i != null) { System.out.println("A possible itinerary is:"); for (Flight flight : i.flights) { System.out.println( " Dep: " + flight.getDepartureCity() + " Dest: " + flight.getDestinationCity()); } } else { System.out.println("No routes for these cities. Please try another."); } } String price = ""; String date = null; while (price.equals("")) { System.out.print("Select a date (aaaa-mm-dd): "); date = input.next(); price = service.checkAvailable(i.getId(), date); if (price.equals("")) { System.out.println("No flights available in that date. Please try another."); } else { System.out.println("The price for this flight is " + price); } } System.out.print( "If you want to proceed with the booking, please insert the credit card. " + "Otherwise insert 0: "); String creditCard = input.next(); if (!creditCard.equals("0")) { BookedFlight booking = new BookedFlight(); booking.setDate(date); booking.setItineraryId(i.getId()); booking = service.postBooking(booking, creditCard); System.out.println("Your booking id is " + booking.getBookingId() + "."); System.out.println("Your flight was booked with success!"); } }