コード例 #1
0
while menu_selection != "5":
    """
    Display menu options until user chooses to end program
        While loop runs until user selects quit option (menu_selection = 5)
               "1 : Start delivery route" - Deliver packages, displays deliveries as they occur
               "2 : Get status of package by package id" - Get and displays status of single package
               "3 : Get status of packages at specific time" - Get and displays status of packages at a specific time
               "4 : Get status of all packages" - Get and displays status of all packages after delivery route completion
               "5 : End delivery route"
        Helper functions from the Helper class provide the logic for each menu_selection
        Truck loads (lists) manually created to efficiently load truck while taking into account special instructions
        All truck loads are stored in a 2D list for each retrieval within start_delivery_route()
        Helper.clock datetime initialized to beginning of day 08:00:00
        Delivery of all packages orchestrated - Truck.start_delivery_route()
    """
    menu_selection = Helper.display_menu(route_started)

    # delivery route starts if user selects 1 and the route has not started yet
    if menu_selection == "1" and not route_started:
        route_started = True
        print("\n[Delivery Route Started]")

        truck1 = Truck(1, "Driver 1")
        truck2 = Truck(2, "Driver 2")

        # Assign packages to truck for each visit to hub
        truck1_first_load = [4, 13, 14, 15, 16, 17, 19, 20, 21, 34, 39, 40]
        truck2_first_load = [
            1, 2, 3, 5, 7, 8, 18, 22, 27, 29, 30, 33, 35, 36, 37, 38
        ]
        truck1_second_load = [6, 10, 11, 12, 25, 26, 28, 31, 32]