def search_flights(): FLAG=0 try: source=input("Enter the source:") ViewValidations.validate_source(source) destination=input("Enter the destination:") ViewValidations.validate_destination(destination) time=input("Enter the time") list_of_flights=ViewValidations.validate_view(source,destination,time) if(list_of_flights!=None): FLAG=1; for flight in list_of_flights: print(flight.get_flight_id()," ",flight.get_flight_name()," ", flight.get_departure_time()," ", flight.get_adult_fare()," ",flight.get_child_fare(), flight.get_duration()) print() choice=input("Do you wish to continue booking? Enter 'Y' or 'N' ") if(choice=="Y"): flightid=input("Enter the flight Id") flight_booking.flight_booking(flightid) except CustomExceptions.InvalidSourceException as e: print(e) except CustomExceptions.InvalidDestinationException as e: print(e) except CustomExceptions.InvalidTimeException as e: print(e) except CustomExceptions.NoFlightFoundException as e: print(e) except Exception as e: print(e) finally: if(FLAG==0): search_flights()
def view_product(): try: category = input("Enter a Restaurant Name: ") print() ''' Validate the user input ''' list_of_products = ViewValidations.validate_view(category) ''' Print the details ''' for product in list_of_products: print(product.get_product_id(), " ", product.get_product_name(), " ", product.get_price()) print() choice = input("Do you want to purchase a product? Enter 'Y' or 'N' ") if (choice == "Y"): product_id = input("Enter the product Id") ''' Here we are invoking a dummy function and passing the data to it. This dummy function has to be completed by another programmer. ''' PurchaseFunctions.purchase_product(product_id) ''' Handle all the exceptions that can occur ''' except InvalidCategoryException as e: print(e) except Exception as e: print("Sorry. Some system error occurred") print(e) print()
def search_advance(): try: p_source=input("Enter the source:") ViewValidations.validate_source(p_source) p_destination=input("Enter the Destination:") ViewValidations.validate_destination(p_destination) print("Available options are:\n") print("=====================") res1=get_flight_with1Hop(p_source,p_destination) res2=get_flight_with2Hop(p_source,p_destination) if(res1==False and res2==False): print("No option") except CustomExceptions.InvalidSourceException as e: print(e) except CustomExceptions.InvalidDestinationException as e: print(e)