Ejemplo n.º 1
0
def main():
    cinema = Cinema()
    command_parser = CommandParser(cinema)

    while True:
        command = input("> ")
        command_parser.handle_command(command)
def main():
    engine = create_engine("sqlite:///cinema.db")
    Base.metadata.create_all(engine)
    session = Session(bind=engine)
    cinema_city = Cinema(session)
    new_movies_and_projections_in_cinema(cinema_city)
    command_parser = CommandParser()
    command_parser.add_command("show_movies", cinema_city.show_movies)
    cinema_city.show_movies(session)
    command = input(">>>")
    command_parser.run_command(command)
Ejemplo n.º 3
0
 def get_film(self):
     cinema = Cinema()
     driver = webdriver.Chrome()
     driver.get("https://generator-online.com/movies/")
     time.sleep(1)
     btn_element = driver.find_element_by_css_selector(
         "button[class^='btn-floating'] span").click()
     time.sleep(1)
     cinema.title = driver.find_element_by_id('title').text
     cinema.genre = driver.find_element_by_id('genres').text
     cinema.year = driver.find_element_by_id('release_date').text
     cinema.overview = driver.find_element_by_id('overview').text
     driver.close()
     return cinema
Ejemplo n.º 4
0
def create_cinema_db():
    cinema = Cinema(10, 10)
    movies = [
        {"name": 'The Hunger Games: Catching Fire',
         "rating": 7.9},
        {'name': 'Wreck-It Ralph',
         'rating': 7.8},
        {'name': 'Her',
         'rating': 8.3}
    ]

    projections = [
        {'movie_id': 1, 'type': '3D',
            'date': '2014-04-01', 'time': '19:10'},
        {'movie_id': 1, 'type': '2D',
            'date': '2014-04-01', 'time': '19:00'},
        {'movie_id': 1, 'type': '4DX',
            'date': '2014-04-02', 'time': '21:00'},
        {'movie_id': 3, 'type': '2D',
         'date': '2014-04-05', 'time': '20:20'},
        {'movie_id': 2, 'type': '3D',
            'date': '2014-04-02', 'time': '22:00'},
        {'movie_id': 2, 'type': '2D',
         'date': '2014-04-02', 'time': '19:30'}
    ]

    reservations = [
        {'username': '******', 'projection_id': 1,
         'row': 2, 'col': 1},
        {'username': '******', 'projection_id': 1,
         'row': 3, 'col': 5},
        {'username': '******', 'projection_id': 1,
         'row': 7, 'col': 8},
        {'username': '******', 'projection_id': 3,
         'row': 1, 'col': 1},
        {'username': '******', 'projection_id': 3,
         'row': 1, 'col': 2},
        {'username': '******', 'projection_id': 5,
         'row': 2, 'col': 3},
        {'username': '******', 'projection_id': 5,
         'row': 2, 'col': 4},
    ]

    for movie in movies:
        cinema.add_movie(**movie)
    for projection in projections:
        cinema.add_projection(**projection)
    for reservation in reservations:
        cinema.add_reservation(**reservation)
Ejemplo n.º 5
0
def main():
    options = [new_room, new_film, sell_ticket, reset_room, show_room]
    cinema = Cinema()
    while True:
        print("************")
        menu()
        n = utils.read_int("Selecciona una opción: ")
        if n is not None:
            if n == 0:
                break
            elif n > 0 and n < 6:
                options[n - 1](cinema)
            else:
                print("Opción incorrecta")

    print("Hasta pronto!")
Ejemplo n.º 6
0
    def add_cinema(self):
        name = input('name: ')
        if not name:
            print('Invalid input!')
            return
        if self.cinemas.exists(name):
            print('cinema already exists!')
            return
        city = input('City: ')
        seats = input('Seats: ')

        cinema = Cinema(name, city, seats)

        if cinema:
            self.cinemas.insert(cinema)
            print('Added:', cinema)
Ejemplo n.º 7
0
def main():
    Base.metadata.create_all(engine)
    arena = Cinema()

    while True:
        command = input(">>>")
        if command == 'add_movie':
            arena.add_movie()
        elif command == 'add_projection':
            arena.add_projection()
        elif command == 'add_reservation':
            arena.add_reservation()
        elif command == 'show_movies':
            arena.show_movies()
        elif command == 'show_movie_projections':
            arena.show_movie_projections(1, '2014-03-22')
Ejemplo n.º 8
0
def main():
    engine = create_engine("sqlite:///cinema.db")
    base.Base.metadata.create_all(engine)

    session = Session(bind=engine)

    cinema = Cinema(session)

    print_menu()
    command = input("Enter your choice: ")
    put = command.split(" ")

    while put[0] != "end":
        if put[0] == "add_movie" or put[0] == '1':
            cinema.add_movie()
        if put[0] == "show_movies" or put[0] == '2':
            cinema.show_movies()
        if put[0] == "add_projection" or put[0] == '3':
            cinema.add_projections()
        if put[0] == "show_movie_projections":
            cinema.show_movie_projections(put[1])
        if put[0] == "make_reservation" or put[0] == '5':
            #ENTER INFORMATION FOR USER
            try:
                #USER INFORMATION
                user_info = step_one(cinema)
                #CHOOSING MOVIE
                movie_choice = step_two(cinema)
                # CHOOSING PROJECTIONS
                projection_choice = step_three(cinema)
                # CHOOSING SEATS
                step_four(cinema, user_info, projection_choice, movie_choice)
                # FINALIZE
                step_five(cinema, user_info, projection_choice)
            except GiveUpError:
                print("You just give up the reservation!")
                print_menu()

        if put[0] == "cancel_reservation":
            cinema.cancel_reservation(put[1])
        if put[0] == "exit":
            break
        if put[0] == "help":
            cinema.print_menu()
        command = input("Enter your choice: ")
        put = command.split(" ")
    def test_a(self):
        self.cinema = Cinema("test1.db")

        self.cinema.add_movie('The Hunger Games: Catching Fire', 7.9)
        self.cinema.add_movie('Wreck-It Ralph', 7.8)
        self.cinema.add_movie('Her', 8.3)

        self.cinema.add_projection(1, '3D', '2014-04-01', '19:10')
        self.cinema.add_projection(1, '2D', '2014-04-01', '19:00')
        self.cinema.add_projection(1, '4DX', '2014-04-02', '21:00')
        self.cinema.add_projection(3, '2D', '2014-04-05', '20:20')
        self.cinema.add_projection(2, '3D', '2014-04-02', '22:00')
        self.cinema.add_projection(2, '2D', '2014-04-02', '19:30')

        self.cinema.add_reservation('RadoRado', 1, 2, 1)
        self.cinema.add_reservation('RadoRado', 1, 3, 5)
        self.cinema.add_reservation('RadoRado', 1, 7, 8)
        self.cinema.add_reservation('Ivo', 3, 1, 1)
        self.cinema.add_reservation('Ivo', 3, 1, 2)
        self.cinema.add_reservation('Mysterious', 5, 2, 3)
        self.cinema.add_reservation('Mysterious', 5, 2, 4)
Ejemplo n.º 10
0
def buy_a_ticket():

    greenmile = The_Green_Mile()
    # print(greenmile.num_seats())
    shawredemption = The_Shawshank_Redemption()
    # print(shawredemption.num_seats())
    # print(greenmile.get_name())
    f = Cinema("MON15", greenmile)
    f.allocate_person("Anna B.", "2A")
    f.allocate_person("Ewa F.", "2D")
    f.allocate_person("Marcin M.", "4C")
    f.relocate_person("2A", "12B")
    f.relocate_person("2D", "13B")
    f.relocate_person("4C", "12C")
    # print(f.time)
    # print(f.get_day())
    # print(f.get_hour())
    # print(f.get_movie())
    pprint(f.seats)
    print(f.get_empty_seats())
    ticket_printer("Anna Kowalska", "5B", "The Green Mile", "SAT12")
    f.print_tickets(ticket_printer)
Ejemplo n.º 11
0
def main():
    engine = create_engine("sqlite:///EmilCinema.db")
    Base.metadata.create_all(engine)
    session = Session(bind=engine)
    EmilCinema = Cinema(session)
    print_main_menu()
    print("asda")
    command = input("Enter your choice: ")
    parsed_command = command.split()
    while parsed_command[0] != "end":
        if parsed_command[0] == "add_movie" or parsed_command[0] == '1':
            EmilCinema.add_movie()
        if parsed_command[0] == "show_movies" or parsed_command[0] == '2':
            EmilCinema.show_movies()
        if parsed_command[0] == "add_projection" or parsed_command[0] == '3':
            EmilCinema.add_projection()
        if parsed_command[0] == "show_movie_projections" or parsed_command[0] == '4':
            EmilCinema.show_projections_available_spots(parsed_command[1])
        if parsed_command[0] == "make_reservation" or parsed_command[0] == '5':

            try:
                user_info = personal_info(EmilCinema)
                movie_id = choosing_movie(EmilCinema)
                projection_id = choosing_projection(EmilCinema)
                choosing_seats(EmilCinema, user_info, projection_id, movie_id)
                finalize_reservation(EmilCinema, user_info, projection_id)

            except GiveUpError:
                print("You just give up the reservation!")
                print_main_menu()
            if parsed_command[0] == "cancel_reservation":
                EmilCinema.cancel_reservation(parsed_command[1])
            if parsed_command[0] == "exit":
                break
            if parsed_command[0] == "help":
                EmilCinema.print_main_menu()
        command = input("Enter your choice: ")
        parsed_command = command.split()
Ejemplo n.º 12
0
from cinema import Cinema

row = int(input('Enter the number of rows:\n'))
seats = int(input("Enter the number of seats in each row:\n"))
while (True):
    ch = input(
        "1. Show the seats\n2. Buy a ticket\n3. Statistics\n4. Show booked Tickets User Info\n0. Exit\n"
    )
    if ch == "1":
        obj = Cinema()
        obj.show_seats(row, seats)

    if ch == "2":
        obj = Cinema()
        obj.buy_ticket(row, seats)

    if ch == "3":
        obj = Cinema()
        obj.show_statistics(row, seats)

    if ch == "4":
        obj = Cinema()
        obj.show_booked_ticket()

    if ch == "0":
        obj = Cinema()
        obj.exit_method()
        break
Ejemplo n.º 13
0
def buyTicket(user):
    db = DB()
    data = db.select('Cinemas', ['id', 'name'])
    # Choose cinema
    while True:
        print()
        for dt in data:
            print(dt[0], dt[1])
        request = input("\n<> Choose one of these cinemas:\n>> ")
        if request == 'back':
            return False, "Back"
        try:
            request = int(request)
        except:
            print('\n!!! Please, enter INTEGER number!')
            continue
        if request < 1 or request > len(data):
            print(
                "\n!!! Сhoose cinemas that do not exceed the number of cinemas"
            )
            continue
        cinema = Cinema(data[request - 1][0], data[request - 1][1])
        # Choose movie
        while True:
            print()
            for kino in cinema.listKino:
                print(kino["id"], kino["name"])
            request = input("\n<> Choose the movie you want to watch:\n>> ")
            if request == "back":
                break
            try:
                request = int(request)
            except:
                print('\n!!! Please, enter INTEGER number!')
                continue
            if request < 1 or request > len(cinema.listKino):
                print(
                    "\n!!! Choose films that do not exceed the amount of film")
                continue
            cinema.setChosenKino(request - 1)
            # Choose time
            while True:
                print("\n", "ID", "Time", "Price")
                time_id = 1
                for time in cinema.getTimes():
                    print(time_id, time['time'], time['price'])
                    time_id += 1
                request = input("\n<> Choose one of these times:\n>> ")
                if request == "back":
                    break
                try:
                    request = int(request)
                except:
                    print('\n!!! Please, enter INTEGER numbers!')
                    continue
                if request < 1 or request > time_id:
                    print(
                        "\n!!! Select a time that does not exceed the ID time")
                    continue
                cinema.setChosenTime(cinema.getTimes()[request - 1]['id'])
                # Choose place
                placeArr = []
                while True:
                    print()
                    for place in cinema.getPlaces():
                        if place['status'] == 0:
                            print(place['place'], end="  ")
                            placeArr.append(place['place'])
                    request = input(
                        "\n<> Select one or more places (with a space):\n>> ")
                    if request == "back":
                        break
                    try:
                        request = [int(i) for i in request.split()]
                    except:
                        print('\n!!! Please, enter INTEGER numbers!')
                        continue
                    ch = True
                    for req in request:
                        if not req in placeArr:
                            ch = False
                            break
                    if not ch:
                        print("<> Please select only free places!")
                        continue
                    else:
                        cinema.setChosenPlaces(request)
                        print("Perfect thank you!")
                        return True, cinema
Ejemplo n.º 14
0
# 3 - create a new session
session = base.Session()


# 4 - create films
#bourne_identity = Film("The Bourne Identity", 2002, "Action", 119)
#furious_7 = Film("Furious 7", 2015, "Action", 137)
#pain_and_gain = Film("Pain & Gain", 2013, "Comedy", 129)
#session.add(bourne_identity)
#session.add(furious_7)
#session.add(pain_and_gain)
#c1 = Cinema("123", "123")
#session.add(c1)

#Cinema
cinema1 = Cinema("Kiev", "Velyka Vasylkivska Street, 19")
cinema2 = Cinema("October", "Konstantinovskaya Street, 26")
cinema3 = Cinema("Torch", "Mykola Bazhana Avenue, 3")

#Film
film1 = Film("InterStellar", 2014, "Fantastic", 168)
film2 = Film("Joker", 2019, "Drama", 116)
film3 = Film("Gentlemen", 2019, "Criminal", 113)

#Session
session1 = Session("2020-09-17", "Almandine", film1)
session1.cinemas = [cinema1]
session2 = Session("2020-09-17", "Ultramarine", film2)
session2.cinemas = [cinema2]
session3 = Session("2020-09-18", "Terracotta", film3)
session3.cinemas = [cinema3]
Ejemplo n.º 15
0
from cinema import Cinema
from command_parser import CommandParser
from connections import *

cinema = Cinema(10, 10)


def create_command_parser():
    command_parser = CommandParser()
    command_parser.add_command('show_movies', show_movies)
    command_parser.add_command('show_movie_projections',
                               show_movie_projections)
    command_parser.add_command('make_reservation', make_reservation)
    command_parser.add_command('cancel_reservation', cancel_reservation)
    command_parser.add_command('exit', exit)
    command_parser.add_command('help', show_help)
    return command_parser


def show_movies():
    print('Current movies:')
    print(cinema.show_movies())


def show_movie_projections(movie_id, date=None):
    projections_info = cinema.show_movie_projections(movie_id, date)
    if date:
        print('Projections for movie {} on {}:'.format(
            projections_info['movie_name'], date))
    else:
        print('Projections for movie {}:'.format(
Ejemplo n.º 16
0
	def setUp(self):
		self.cinema = Cinema("test1.db")
Ejemplo n.º 17
0
from flask import Flask
from flask_restful import Resource, Api, reqparse, request
from cinema import Cinema
from datetime import datetime

app = Flask(__name__)
api = Api(app)
app.config['SECRET_KEY'] = 'e3esacosdncwefn3rif3ufcs'

basePath = '/api/v1'  #uguale a quello nel file .yaml
c = Cinema()


# validatori dei parametri, data e time
def validDate(date):
    try:
        datetime.strptime(date, '%d%m%Y')
        return True
    except ValueError:
        return False


def validTime(time):
    if time in ['19:30', '21:00', '22:30']:
        return True
    return False


# convertiamo seat in in numero e viceversa

Ejemplo n.º 18
0
	def __init__(self, db_name):
		self.cinema = Cinema(db_name)
Ejemplo n.º 19
0
from datetime import datetime
from flask import Flask, request
from flask_restful import Resource, Api, reqparse
from cinema import Cinema
from urllib.parse import quote

app = Flask(__name__)
api = Api(app)

basePath = '/api/v1'

cinema = Cinema()


def validDate(date):
    try:
        datetime.strptime(date, '%d%m%Y')
        return True
    except ValueError:
        return False


def validTime(time):
    if time in ["19:30", "21:00", "22:30"]:
        return True
    return False


def SeatToInt(seat):
    return (ord(str.upper(seat['row'])) - ord('A')) * 10 + seat['seat']
Ejemplo n.º 20
0
from IPython.display import clear_output
from cinema import Seat, Cinema
from user import User
import mysql.connector

rows = int(input('Enter the number of rows: '))
columns = int(input('Enter the number of columns: '))
cinema = Cinema(rows, columns)


def start_screen():
    print('''Enter your option
    1. Show the seats
    2. Buy a ticket
    3. Statistics
    4. Show booked Tickets User Info
    0. Exit
    ''')
    option = int(input())
    return option


def create_user():
    infos = ['name', 'gender', 'age', 'phoneNo']
    inpt = []
    for info in infos:
        inpt.append(input(f'Enter your {info}: '))
    user = User(inpt[0], inpt[1], int(inpt[2]), int(inpt[3]))
    return user

Ejemplo n.º 21
0
import unittest
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from cinema import Cinema


engine = create_engine("sqlite:///cinema.db")
session = Session(bind=engine)

cinema = Cinema(session)


class Create_cinema_test(unittest.TestCase):

    def test_get_date_time(self):
        result = cinema._get_movie_date_time(1)
        self.assertEqual(result, ("2014-04-01", "19:10"))

    def test_get_movie_name(self):
        movie = cinema._get_movie_name(1)
        self.assertEqual(movie, "The Hunger Games: Catching Fire")
if __name__ == '__main__':
    unittest.main()
Ejemplo n.º 22
0
 def setUp(self):
     self.my_cinema = Cinema(session)
from cinema import Cinema
from user_interface import *

gornik = Cinema('Gornik')
gornik.add_room('A', (11, 11))
gornik.add_room('B', (12, 12))
gornik.movie_generator()
gornik.allocation_seat_generator()
show_interface(gornik)

Ejemplo n.º 24
0
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from cinema import Cinema

db = 'cinema.db'
Base = declarative_base()
engine = create_engine("sqlite:///cinema.db")
Base.metadata.create_all(engine)
session = Session(bind=engine)

cinema = Cinema(session, db)

cinema.clear_reservation_on_startup()


def start_mess():
    start_message = "Hello, here is the cinema. You can \
use one of the the following commands:\
\n show_movies - print all movies ordered by rating\
\n show_movie_projections <movie_id> - \
print all projections of a given movie\
\n make_reservation\
\n cancel_reservation <name> - disintegrate given person's reservation\
\n exit\
\n help"

    return start_message


def print_func(set_obj):