def print_show_movie_projections_with_date(self, movie_id, movie_date): movie_name_date = self.cursor.execute( "SELECT Movies.movie_name, Projections.movie_date \ FROM Movies JOIN Projections \ ON Movies.movie_id = ? AND Projections.movie_date = ?", ( movie_id, movie_date, )) m_name = "" m_date = "" for name_and_date in movie_name_date: m_name = name_and_date[0] m_date = name_and_date[1] print("Projections for movie '%s' on date '%s':" % (m_name, m_date)) projections_cursor = MagicReservationSystem( ).show_movie_projections_with_date(movie_id, movie_date) if len(projections_cursor.fetchall()) == 0: message = "There are no projections for this movie on this date!" print(message) return for projections in MagicReservationSystem( ).show_movie_projections_with_date(movie_id, movie_date): print("[{}]".format(projections[0]), projections[1], "({})".format(projections[2]))
def print_show_movie_projections(self, movie_id): movie_name = self.cursor.execute( "SELECT movie_name \ FROM Movies \ WHERE movie_id = ?", (movie_id, )) title = "" for name in movie_name: title = name[0] projections_cursor = MagicReservationSystem().show_movie_projections( movie_id) if len(projections_cursor.fetchall()) == 0: message = "\nMovie with this id doesn't exist!" print(message) return print("Projections for movie '%s': " % title) for projections in MagicReservationSystem().show_movie_projections( movie_id): print("[{}]".format(projections[0]), projections[1], projections[2], "({})".format(projections[3]), projections[4], "available spots")
def show_available_seats(self, projection_id): size_of_the_hall = MagicReservationSystem().show_cinema_hall( projection_id) every_row = "" print("Available seats (marked with a dot):") print(" 1 2 3 4 5 6 7 8 9 10") for row, rows in enumerate(size_of_the_hall): for col, cols in enumerate(rows): if col == 0 and row < 9: every_row += str(row + 1) + " " if col == 0 and row == 9: every_row += str(row + 1) + " " every_row += str(cols) + " " print(every_row) every_row = ""
def main(): while True: print("\nWelcome to our cinema!\n") print("For Movies: Press 1") print("For Projections: Press 2") print("To make reservation: Press 3") print("For Help: Press 4") print("To Exit: Press 5") try: command = int(input("Please choose command>> ")) if command < 1 or command > 5: print("\nWrong choice! Try again!") if command == 1: PrepareData().print_show_movies() elif command == 2: movie_id = int(input("Please choose movie id>> ")) PrepareData().print_show_movie_projections(movie_id) elif command == 3: username = input("Choose name>> ") client_username = CLI().enter_name(username) number_of_tickets = int(input("Choose number of tickets>> ")) client_tickets = CLI().enter_number_of_tickets(number_of_tickets) PrepareData().print_show_movies() movie_id = int(input("Please choose movie id>> ")) client_movie = CLI().choosen_movie(movie_id) PrepareData().print_show_movie_projections(movie_id) projection_id = int(input("Please choose projection id>> ")) if projection_id not in CLI().validate_projection(movie_id): print("\nInvalid projection id!") continue data_and_time_of_projection = CLI().choosen_date_and_time(projection_id) if client_tickets > MagicReservationSystem().available_spots_in_cinema(projection_id): message = "\nThe tickets are more than the available spots in the cinema hall!" print(message) continue PrepareData().show_available_seats(projection_id) seats = "" while client_tickets != 0: seat = tuple(int(x.strip()) for x in input("Choose seat: ").split(',')) #print(MagicReservationSystem().choose_seats(seat[0], seat[1], projection_id)) #seats += str(seat) + "," #client_seats = CLI().choosen_seats(seats, projection_id) print(MagicReservationSystem().choose_seats(seat[0], seat[1], projection_id)) MagicReservationSystem().choose_seats(seat[0], seat[1], projection_id) client_tickets -= 1 #print(client_seats) elif command == 4: print("\nFor movies - Show all movies in the cinema") print("For Projections - Show all projections for given movie") print("To make reservation - You can make reservations in our cinema") print("To Exit - You can exit from the system") elif command == 5: break except ValueError: print("\nPlease enter a valid value!")
def print_show_movies(self): print("Current movies: ") for movies in MagicReservationSystem().show_movies(): print("[{}]".format(movies[0]), movies[1], "({})".format(movies[2]))