Пример #1
0
def make_reservation(database):
    username = input("Step 1 (User): Choose name> ")
    if is_giving_up(username):
        return
    tickets = input("Step 1 (User): Choose number of tickets> ")
    if is_giving_up(tickets):
        return
    else:
        tickets = int(tickets)

    show_movies(database)
    movie_id = input("Step 2 (Movie): Choose a movie> ")
    if is_giving_up(movie_id):
        return

    show_movie_projections(database, movie_id)
    projection_id = choose_projection(database, tickets)
    if projection_id == GIVE_UP:
        return

    available_spots(database, projection_id)

    chosen_seats = choose_seats(database, projection_id, tickets)
    if choose_seats == GIVE_UP:
        return

    reservation_info(database, movie_id, projection_id, sorted(chosen_seats))

    finalize(database, username, projection_id, chosen_seats)
    if finalize == GIVE_UP:
        return
Пример #2
0
def interface():

    print("You now have access to the cinema database,"
          "\ntype 'help' to see available options!")

    database = sqlite3.connect(DATABASE_FILE)
    database.row_factory = sqlite3.Row

    while True:
        user_choice = input("\ncommand> ")

        command = user_choice.split()[0]
        arguments = user_choice.split()[1:]

        if command == 'exit':
            break
        elif command == 'help':
            help()
        elif command == 'show_movies':
            show_movies(database)
        elif command == 'make_reservation':
            make_reservation(database)
        elif command == 'show_movie_projections':
            if len(arguments) == 2:
                show_movie_projections(database, arguments[0], arguments[1])
            else:
                show_movie_projections(database, arguments[0])
        elif command == 'cancel_reservation':
            cancel_reservation(database, arguments[0])
        else:
            print("There is no such command, try again!")

    database.close()