Пример #1
0
def initialize_airplane(debug=False, capacity=0.0, option=0):

    if debug:
        plane = Airplane(airplane_choices[option])
        plane.create_cabin(capacity)

    else:
        # CHOOSE AIRPLANE MODEL
        option = len(airplane_choices)
        attempts = 3

        # have a prompt to select airplane: use input to select 0, 1, 2
        print("Choose an Airplane Model")
        for opt, apln in airplane_choices.items():
            print("\tEnter {} for {}".format(opt, apln))

        while option not in list(airplane_choices.keys()):
            input_plane_option = input("Enter Option: ")
            print()

            try:
                assert isinstance(int(input_plane_option),
                                  int), "\nNOT A VALID ENTRY. TRY AGAIN"
                option = int(input_plane_option)
                assert option in list(range(
                    0, len(airplane_choices))), "\nNOT A VALID AIRPLANE CHOICE"
            except Exception as e:
                attempts -= 1
                print(e)
                print("\tRemaining Attempts: {}\n".format(attempts))

        ### BUILD AIRPLANE
        plane = Airplane(airplane_choices[option])

        # now enter a capacity:
        attempts = 3
        print("Set a value between 0-100 for capacity (%)")
        capacity = None
        while capacity is None and attempts > 0:
            capacity = input("Enter Value: ")
            try:
                assert isinstance(float(capacity),
                                  float), "\n NOT A VALID ENTRY. TRY AGAIN"
                capacity = float(capacity) / 100

            except Exception as e:
                print(e)
                capacity = None
                attempts -= 1
                print("\tRemaining Attempts: {}\n".format(attempts))

        plane.create_cabin(capacity)

    return plane
Пример #2
0
                os.system("clear")

                # reset to aisle symbol
                airplane.cabin.iloc[row - airplane.start_row, aisle] = '| |'
            else:
                pass

    sys.stdout.write(Status_Msg)
    airplane.cabin.to_csv(sys.stdout)


LOCAL_RESULTS_DIR = os.path.join(LOCAL_REPO_DIR, "results")
fn = os.path.join(LOCAL_RESULTS_DIR, "Airbus_380/run_003.csv")
airplane_model = os.path.basename(os.path.dirname(fn))

my_plane = Airplane(airplane_model)
my_plane.create_cabin(1)

passenger_df = pd.read_csv(fn, dtype=object)
try:
    passenger_df = passenger_df.drop(['Unnamed: 0'], axis=1)
except:
    pass

#-------------------------------
# my attempt at animation
#-------------------------------

show_boarding(passenger_df, my_plane)
time.sleep(10)