import math import os import sys import time import random #----------------CLASS---KEY------------------------------------------ class Key: how_many_keys = 0 # Initialisation of keys def __init__(self, keynumber): self.number = keynumber self.possessor = "Rezeption" #where are the keys def status_key(self, keynumber=None): print("Schlüssel", self.number, "im Besitz", self.possessor) def hand_out_key(self, keynumber, Guest): self.possessor = Guest def get_back_key(self, keynumber): self.possessor = "Rezeption" # Generates all the keys, two for each room # results in keynumbers: 11, 12, 21, 22, 31, 32, 41, 42 key_list = [] for i in range(11, 42, 10): a = "key_" + str(i) + " = Key(" + str(i) + ")" exec(a) a2 = "key_list.append(key_" + str(i) + ")" exec(a2) b = "key_" + str(i+1) + " = Key(" + str(i+1) + ")" exec(b) b2 = "key_list.append(key_" + str(i+1) + ")" exec(b2) #----------------CLASS---CLIENT------------------------------------------ checked_in_list = [] client_list = [] all_clients = [] class Client(): months = ['Januar', 'Februar','März','April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'] clients = 0 def __init__(self, name: str, surname: str, client_num: str, room: str, period, key_num: int, bookings, status: bool,\ checked_in: bool): self.name = name self.surname = surname self.client_num = client_num self.room = None self.period = period self.key_num = 0 self.bookings = [] self.status = False self.checked_in = checked_in # Automatic status adjustment if len(self.bookings) >= 4: self.status = True Client.clients += 1 def check_in(self, room, key_num, period): print("Check In") self.checked_in = True self.period = str(period) room_list[reference.index(str(room))].occupy(self.surname, self.period) self.room = str(room) num_ = "key_" + str(key_num) + ".hand_out_key(" + str(key_num) + "," + "'" + str(self.surname) + "')" try: exec(num_) self.key_num = key_num checked_in_list.append(self.client_num) client_list.remove(str(self.client_num)) if self.status == True: print("Der Kunde besitzt VIP Previlegien. Er erhält kostenloses \ Frühstück sowie die kostenlose Benutzung der Mini-Bar.") except: ("Schlüssel mit Daten nicht gefunden.") new_bill = add_bill(self.name, self.surname, self.client_num, room, self.period) return new_bill def check_out(self): room_list[reference.index(self.room)].free() key_num = self.key_num num_ = "key_" + str(key_num) + ".get_back_key(" + str(key_num)+ ")" try: exec(num_) print("Der Gast ist erfolgreich ausgecheckt worden.") self.checked_in = False self.room = None self.period = None self.key_num = None checked_in_list.remove(self.client_num) client_list.append(self.client_num) except: ("Schlüssel mit Daten nicht gefunden.") def client_bill(self, bill_num): self.bookings.append(str(bill_num)) def client_bill_delete(self, bill_num): if bill_num in self.bookings: self.bookings.remove(bill_num) print("Rechnung wurde beim Gast", self.client_num, "gelöscht.") def vip_status(self): if len(self.bookings) > 3: self.status = True # Length of stay as print def period_print(self): stay_period = [] num_string = "" for i in self.period: if i.isnumeric(): num_string += i if i == ",": stay_period.append(num_string) num_string = "" stay_period.append(num_string) stay_period = tuple(stay_period) # Same month if stay_period[1] == stay_period[3]: days = int(stay_period[0]) - int(stay_period[2]) month_num = int(stay_period[1]) - 1 month_print = Client.months[month_num] print("Der Kunde bleibt", abs(days), "Tage.") print("Vom", stay_period[0], "bis", stay_period[2], month_print) # Across months if stay_period[1] != stay_period[3]: # Stay period more than 1 month if int(stay_period[3]) - int(stay_period[1]) > 1: days = 28 - int(stay_period[0]) + int(stay_period[2]) + \ ((int(stay_period[3]) - int(stay_period[1])-1) * 28) # Stay period else: days = 28 - int(stay_period[0]) + int(stay_period[2]) month_num_1 = int(stay_period[1]) - 1 month_num_2 = int(stay_period[3]) - 1 month_print_1 = Client.months[month_num_1] month_print_2 = Client.months[month_num_2] print("Der Kunde bleibt", abs(days), "Tage.") print("Vom", stay_period[0], month_print_1, "bis", stay_period[2], month_print_2) # Client information def info(self, action = None): dic_ = {"Name" : self.name, "Nachname" : self.surname, "Kundennummer" : self.client_num, "Zimmer" : self.room, "Aufenthaltsdauer": self.period, "Schlüsselnummer" : self.key_num, "Buchungen" : self.bookings, "VIP-Status" : self.status, "Eingecheckt" : self.checked_in } if action != None: # If asked client information is stay period if action == "Aufenthaltsdauer": client_num = self.client_num stay = str(client_num)+ ".period_print()" exec(stay) # If asked client information is different if action != "Aufenthaltsdauer": for i in dic_: if i == action: print(action, "ist", dic_[i]) else: for i in dic_: print(i.ljust(16), ": ", dic_[i]) #w43 = Client("David", "Gebert", "w43", "Suite", "01,02,03,03", 22, (51,61,77), False) #w43.period_print() #----------------CLASS--ROOM------------------------------------------ ''' Implementierung der Klasse Zimmer ''' class Room: def __init__(self, room_number, guest=None, period=None): self.number = room_number self.occupied = False self.resident = None self.period = None # Room gets occupied by a client def occupy(self, guest, period): self.occupied = True self.resident = guest self.period = period # Room is no longer occupied def free(self): self.occupied = False self.resident = None self.period = None def is_free(self, client_num, room_name, period): occupied = self.period if occupied == None: room_types = [["Single", 10], ["Double", 20], ["Suite", 30], ["Panorama_Suite", 40]] for i in room_types: if i[0] == room_name: key_num = i[1]+1 #print("Der Kunde erhält den Schlüssel", key_num) check = "exec(" + str(client_num) + ".check_in(" + "'" + str(room_name) + "'" + "," + str(key_num)\ + "," + "'" + str(period) + "'" +"))" print(check) exec(check) else: stay_period = [] num_string = "" for i in self.period: if i.isnumeric(): num_string += i if i == ",": stay_period.append(num_string) num_string = "" stay_period.append(num_string) stay_period_new = [] num_string = "" for i in period: if i.isnumeric(): num_string += i if i == ",": stay_period_new.append(num_string) num_string = "" stay_period_new.append(num_string) #print(stay_period, stay_period_new) if int(stay_period[3]) < int(stay_period_new[1]): room_types = [["Single", 10], ["Double", 20], ["Suite", 30], ["Panorama_Suite", 40]] for i in room_types: if i[0] == room_name: key_num = i[1]+1 #print("Der Kunde erhält den Schlüssel", key_num) check = "exec(" + str(client_num) + ".check_in(" + "'" + str(room_name) + "'" + "," + str(key_num)\ + "," + "'" + str(period) + "'" +"))" print(check) exec(check) if int(stay_period[3]) > int(stay_period_new[1]): print("Das Zimmer", room_name, " ist in dem gewünschten Zeitraum belegt.") if int(stay_period[3]) == int(stay_period_new[1]): if int(stay_period[0]) > int(stay_period_new[2]): print("Das Zimmer", room_name, " ist in dem gewünschten Zeitraum belegt.") if int(stay_period[0]) <= int(stay_period_new[2]): room_types = [["Single", 10], ["Double", 20], ["Suite", 30], ["Panorama_Suite", 40]] for i in room_types: if i[0] == room_name: key_num = i[1]+1 #print("Der Kunde erhält den Schlüssel", key_num) check = "exec(" + str(client_num) + ".check_in(" + "'" + str(room_name) + "'" + "," + str(key_num)\ + "," + "'" + str(period) + "'" +"))" print(check) exec(check) def is_occupied(self, room_name, period): if self.period == None: print("Das Zimmer", str(room_name)," ist frei.") if self.period != None: stay_period = [] num_string = "" for i in self.period: if i.isnumeric(): num_string += i if i == ",": stay_period.append(num_string) num_string = "" stay_period.append(num_string) stay_period_new = [] num_string = "" for i in period: if i.isnumeric(): num_string += i if i == ",": stay_period_new.append(num_string) num_string = "" stay_period_new.append(num_string) #print(stay_period, stay_period_new) if int(stay_period[3]) < int(stay_period_new[1]): print(stay_period[3], stay_period_new[1]) print("Das Zimmer", room_name, "ist in dem gewünschten Zeitraum frei.") if int(stay_period[3]) > int(stay_period_new[1]): print("Das Zimmer", room_name, " ist in dem gewünschten Zeitraum belegt.") if int(stay_period[3]) == int(stay_period_new[1]): if int(stay_period[2]) > int(stay_period_new[0]): print("Das Zimmer", room_name, " ist in dem gewünschten Zeitraum belegt.") #print(stay_period[2], stay_period_new[0]) if int(stay_period[2]) <= int(stay_period_new[0]): print("Das Zimmer", room_name, "ist in dem gewünschten Zeitraum frei.") #print(stay_period[2], stay_period_new[0]) # room information def info(self, action = None): dic_ = {"Nummer" : self.number, "Gast" : self.resident, } if action != None: if action == "Nummer": print("Das Zimmer hat die Nummer", dic_["Nummer"]) if action == "Gast": if dic_["Gast"] != None: print("Das Zimmer", str(self.number), "ist gerade vom Gast", dic_["Gast"], "belegt") else: print("Das Zimmer", str(self.number), "ist im Moment nicht belegt.") else: for i in dic_: print(i.ljust(16), ": ", dic_[i]) # Generates all the rooms # nr.10-"Single", nr.20-"Double", nr.30-"Suite", nr.40-"Panorama_Suite" reference = ["Single", "Double", "Suite", "Panorama_Suite"] room_types = [["Single", 10], ["Double", 20], ["Suite", 30], ["Panorama_Suite", 40]] room_list = [] for i in room_types: tmp = i[0] + " = Room(" + str(i[1]) + ")" exec(tmp) tmp = "room_list.append(" + str(i[0]) + ")" exec(tmp) #----------------CLASS--ACCOUNTING---------------------------- class Accounting(): all_bills = [] counter = 0 def __init__(self, name:str, surname:str, client_num:str, room:str, period:str, bill_num:str, bill_status:bool): print("Wird Ausgeführt") self.name = name self.surname = surname self.client_num = client_num self.period = period self.bill_num = bill_num self.bill_status = bill_status Accounting.counter += 1 room_types = [["Single", 10], ["Double", 20], ["Suite", 30], ["Panorama_Suite", 40]] for i in room_types: if i[0] == room: self.room = i[1] var = str(client_num) + ".client_bill(" + "'" + bill_num + "'" + ")" print(var) exec(var) def show_bill(self): stay_period = [] num_string = "" for i in self.period: if i.isnumeric(): num_string += i if i == ",": stay_period.append(num_string) num_string = "" stay_period.append(num_string) stay_period = tuple(stay_period) # Same month if stay_period[1] == stay_period[3]: days = int(stay_period[0]) - int(stay_period[2]) # Across months if stay_period[1] != stay_period[3]: # Stay period more than 1 month if int(stay_period[3]) - int(stay_period[1]) > 1: days = 28 - int(stay_period[0]) + int(stay_period[2]) + \ ((int(stay_period[3]) - int(stay_period[1])-1) * 28) # Stay period else: days = 28 - int(stay_period[0]) + int(stay_period[2]) days = abs(days) costs = int(days) * int(self.room) """_______________________________________________________________________""" lines = [[] for i in range(13)] lines[0].append( '┌─────────────────────────────┐') lines[1].append( '│ Rechnung │') lines[2].append( '│ │') lines[3].append( '│Kunde: {} {} '.format(self.name, self.surname)) lines[4].append( '│Zimmer: {} '.format(self.room)) lines[5].append( '│Anz. Tage:{} '.format(days)) lines[6].append( '│pro Nacht:{}€ '.format(self.room)) lines[7].append( '│Kosten: {}€ '.format(costs)) lines[8].append( '│ ') lines[9].append( '│Rech. Nr.:{} '.format(self.bill_num,)) lines[10].append('│Beglichen:{} '.format(self.bill_status)) lines[11].append('│ │') lines[12].append('└─────────────────────────────┘') for i in lines: print(i[0]) def pay_bill(self): self.bill_status = True print("Rechnung", self.bill_num, "wurde bezahlt.") def delete_bill(self, bill_num): for i in all_clients: var = str(i) + ".client_bill_delete(" + "'" + bill_num + "'" + ")" exec(var) var_ = str(i) + ".check_out()" exec(var_) def __del__(self): print("Rechnung wurde storniert.") #r43 = Accounting("Karl", "Otto", 16, 21,"2,3,4,5", "", False) #-------------YOU---ARE--LEAVING--CLASS--ACCOUNTING---------------------------- #-------------ADDITIONAL--ACCOUNTING--METHODS-------------------------- bill_list = [] def add_bill(name, surname, client_num, room, period): bill_numb = "r" + str(Accounting.counter) c = bill_numb + " = Accounting(" + '"' + str(name) + '"' + "," + '"' + \ str(surname) + '"' + "," + '"' + str(client_num) + '"' + "," + '"' + str(room) + '"' + "," + '"' + str(period) + \ '"' + "," + '"'+ str(bill_numb) + '"' + ", False)" bill_list.append(bill_numb) return c def show_single_bill(): print("Volgenden Rechnungsnummern stehen zur Auswahl:") print(bill_list) while True: k = input("Rechnungsnummer? ") if k in bill_list or k == "abbrechen": break if k != "abbrechen": try: c = str(k) + ".show_bill()" exec(c) except: print("Rechnung wurde nicht gefunden.") def pay_your_bill(): print("Folgenden Rechnungsnummern stehen zur Auswahl:") print(bill_list) print("Rechungsnummer? ") while True: bill =input().strip().lower() if bill in bill_list or bill == "abbrechen": break if bill != "abbrechen": try: c = str(bill) + ".pay_bill()" exec(c) except: print("Rechung wurde nicht gefunden.") def delete_bill(bill_numb): k = str(bill_numb) + ".delete_bill(bill_numb)" exec(k) #-------------ADDITIONAL---CLIENT---METHODS------------------------- def clear(): if os.name == "posix": os.system("clear") elif os.name in ("nt", "dos", "ce"): os.system('cls') else: print(80 * "\n") def add_client(): while True: name = input("Name : ") if name.isalpha(): break while True: surname = input("Nachname :") if surname.isalpha(): break period = None client_num = "c" + str(Client.clients) room_num = None key_num = None c = str(client_num) + " = Client(" + '"' + str(name) + '"' + "," + '"' + \ str(surname) + '"' + "," + '"' + str(client_num) + '"' + "," + '"' + str(room_num) \ + '"' + "," + '"' + str(period) + '"' + "," + '"'+ str(key_num) + '"' + ",[], False, False)" #print(c) client_list.append(client_num) all_clients.append(client_num) return c k = add_client() exec(k) j = c0.check_in("Suite",31, "2,3,4,5") exec(j) #print(c0.info()) clear() dir_path = os.path.dirname(os.path.realpath(__file__)) imported = True try: import simpleaudio except ModuleNotFoundError: imported = False def play_sound(): if imported: wave_obj = simpleaudio.WaveObject.from_wave_file\ (os.path.join(dir_path, "grandhotel.wav")) play_obj = wave_obj.play() return play_obj return None def stop_sound(play_obj): if play_obj is not None: play_obj.stop() def ascii_print(): with open('ascii_print_hotel', 'r', encoding='utf8') as ascii_: for line in ascii_: sys.stdout.write(line) time.sleep(0.1) system_list = ["1", "2", "3", "4", "5"] """-------------START-----INTERFACE--------------------""" input("Start?") clear() #Intro play_obj = play_sound() #Logo Print ascii_print() print("\t\tWELCOME TO THE GRAND BUDAPEST HOTEL SYSTEM") input("\t\t\tPress enter to continue") clear() while True: print("Im System stehen Ihnen verschiedene Funktionen zur Verfügung.\n") print(""" 1.Buchhaltung 2.Kundenverwaltung 3.Zimmerverwaltung 4.Schlüsselverwaltung 5.Dienstpläne\n""") while True: print("Welches der folgenden Systeme möchten Sie öffnen?") system = input().strip().lower() if system in system_list or system == "beenden": break else: clear() print("Bitte wählen Sie aus einem der bestehenden Systeme aus.") print(""" 1.Buchhaltung 2.Kundenverwaltung 3.Zimmerverwaltung 4.Schlüsselverwaltung 5.Dienstpläne\n""") #"""-----------INTERFACE-----ACCOUNTING------------------""" if system == "1": #Accounting clear() while True: print("Willkommen in der Buchhaltung") print("Welche der folgenen Aktionen möchten Sie ausführen") print(""" 1. Rechnung anzeigen 2. Rechnung bezahlen 3. Rechnung löschen Abbrechen """) account = input().strip().lower() if account == "1": print("Rechnung anzeigen\n") show_single_bill() input() clear() continue if account == "2": print("Rechung bezahlen\n") pay_your_bill() input() clear() continue if account == "3": print("Rechnung löschen\n") while True: print("Folgenden Rechnungsnummern stehen zur Auswahl:") print(bill_list) print("Rechungsnummer? ") bill_numb =input().strip().lower() if bill_numb in bill_list or bill_numb == "abbrechen": break if bill_numb == "abbrechen": clear() break else: delete_bill(bill_numb) # Delete bill at client bill_list.remove(bill_numb) # Delete bill at bill_list delete_ = "del " + bill_numb exec(delete_) # Delete bill in system #### #Kunde auschecken #### input() clear() continue if account == "abbrechen": clear() break #"""-----------INTERFACE-----CLIENT------------------""" if system == "2": #Client clear() while True: print("Willkommen in der Kundenverwaltung") print("Welche der folgenen Aktionen möchten Sie ausführen") print(""" 1. Kunde hinzufügen 2. Kunde anzeigen 3. Kunde einchecken 4. Kunde auschecken 5. Freie Zimmer über Zeitraum anzeigen. Abbrechen """) client = input().strip().lower() if client == "1": print("Kunde hinzufügen\n") c = add_client() exec(c) clear() continue if client == "2": print("Kunde anzeigen\n") print(all_clients) while True: k = input("Über welchen Kunden wollen sie sich Information anzeigen lassen? ") if k in all_clients: break else: print("Dieser Kunde ist leider nicht im System.") c = str(k) + ".info()" exec(c) input() clear() continue if client == "3": print("Kunde einchecken\n") print("Welchen Kunden möchten Sie einchecken?") print(client_list) while True: client = input() if client in client_list: break while True: print(reference) print("Zimmerauswahl") room_ = input() if room_ in reference: break else: print("Dieses Zimmer ist in unserem Hotel leider nicht vorhanden.") print("Aufenthaltszeitraum") while True: day_arrival = input("Anreisetag: ") if day_arrival.isdigit() and 0 < int(day_arrival) and int(day_arrival) < 28: break while True: month_arrival = input("Anreisemonat: ") if month_arrival.isdigit() and 0 < int(month_arrival) and int(month_arrival) < 12: break while True: day_depature = input("Abreisetag: ") if day_depature.isdigit() and 0 < int(day_depature) and int(day_depature) < 28: break while True: month_depature = input("Abreisemonat: ") if month_depature.isdigit() and 0 < int(month_depature) and int(month_depature) < 12: break period = str(day_arrival) + "," +str(month_arrival) + "," + str(day_depature) + "," + str(month_depature) check_ = str(room_) + ".is_free(" + "'" + str(client) + "'" + "," + "'" + str(room_) \ + "'" + "," + "'" + str(period) + "'" + ")" print(check_) exec(check_) clear() continue if client == "4": print("Auschecken\n") print("Welchen Gast möchten Sie auschecken?") print(checked_in_list) while True: client = input() if client in checked_in_list: checking_out = str(client) + ".check_out()" exec(checking_out) break if client == "abbrechen": break clear() continue if client == "5": print("Freie Zimmer anzeigen\n") while True: print("In welchem Zeitraum möchten Sie schauen, ob Zimmer frei sind?") print("Aufenthaltszeitraum") while True: day_arrival = input("Anreisetag: ") if day_arrival.isdigit() and 0 < int(day_arrival) and int(day_arrival) < 28: break while True: month_arrival = input("Anreisemonat: ") if month_arrival.isdigit() and 0 < int(month_arrival) and int(month_arrival) < 12: break while True: day_depature = input("Abreisetag: ") if day_depature.isdigit() and 0 < int(day_depature) and int(day_depature) < 28: break while True: month_depature = input("Abreisemonat: ") if month_depature.isdigit() and 0 < int(month_depature) and int(month_depature) < 12: break period = str(day_arrival) + "," +str(month_arrival) + "," + str(day_depature) + "," + str(month_depature) #print(period) for i in reference: k = str(i) + ".is_occupied(" + "'" + str(i) + "'" + "," + "'" + str(period) + "'" + ")" #print(k) exec(k) input() clear() continue if client == "abbrechen": input() clear() break #"""-----------INTERFACE-----ROOM------------------""" if system == "3": #Room clear() while True: print("\nWillkommen in der Zimmerverwaltung") print("Welche der folgenen Aktionen möchten Sie ausführen") print(""" 1. Zimmerstatus anzeigen Abbrechen """) room_input = input().strip().lower() if room_input == "1": while True: print("Zimmerstatus anzeigen\n") print(reference) print("Name des Zimmers:") dorm = input() if dorm in reference: print(""" 1. Ale Informationen 2. Nummer 3.Gast""") dorm_info = input() if dorm_info == "1": print("Zimmer:", dorm) dorm_exec = str(dorm) + ".info()" exec(dorm_exec) input() clear() break if dorm_info == "2": print("Zimmer:", dorm) dorm_exec = str(dorm) + ".info("+ "'Nummer'" +")" exec(dorm_exec) input() clear() break if dorm_info == "3": print("Zimmer:", dorm) dorm_exec = str(dorm) + ".info("+ "'Gast'" +")" exec(dorm_exec) input() clear() break if dorm_info == "abbrechen": clear() break if room_input == "abbrechen": clear() break if system == "4": #Key clear() while True: print("Willkommen in der Schlüsselverwaltung") print("Welche der folgenen Aktionen möchten Sie ausführen") print(""" 1. Schlüsselstatus anzeigen Abbrechen""") key_input = input().strip().lower() if key_input == "1": while True: print("Schlüsselstatus anzeigen\n") all_key_numbers = ["11", "12", "21", "22", "31", "32", "41", "42"] print(all_key_numbers) key_num = input("Schlüsselnummer ") print("") if key_num in all_key_numbers: key_print = "key_" + key_num + ".status_key()" exec(key_print) input() clear() break if key_num == "abbrechen": clear() break else: print("Was ist schief gelaufen") if key_input == "abbrechen": clear() break if system == "5": #duty_roster clear() def duty_roster_write(): with open('dienstplan.txt', 'w', encoding='utf8') as d: employees = ['M. Gustave', 'Zero Mustafa', 'M. Jean', 'Agatha', 'M. Chuck'] job = ['Concierge', 'Lobby-Boy', 'Rezeptionist', 'Portier'] i = 1 while i < 53: random.shuffle(employees) random.shuffle(job) a = "KW" + str(i) d.write(a + "#" + employees[0] + ": " + job[0] + "#" + employees[1]\ + ": " + job[1] + "#" + employees[2] + ": " + job[2] + "#" + employees[3] + ": " \ + job[3] + "#" + "frei: " + employees[4] + "\n") i += 1 def duty_roster_read(): with open('dienstplan.txt', 'r', encoding='utf8') as d: for line in d: print(line) while True: print("\nWillkommen dei den Dienstplänen") print("Welche der folgenen Aktionen möchten Sie ausführen") print(""" 1. Dienstplan erstellen und anzeigen 2. Dienstplan exportieren 3. Dienstplan importieren Abbrechen""") duty = input().strip().lower() if duty == "1": try: duty_roster_write() duty_roster_read() except: print("Es konnte kein Dienstplan erstellt werden.") input() clear() continue if duty == "2": try: duty_roster_write() print("Der Dienstplan wurde erfolgreich exportiert.") except: print("Der Diensplan konnte nicht exportiert werden.") input() clear() continue if duty == "3": try: duty_roster_read() except: print("Es konnte kein Dienstplan unter dem Namen \ dienstplan.txt im Verzeichnis gefunden werden.") input() clear() continue if duty == "abbrechen": input() clear() break if system == "beenden": clear() print("The Grand Budapest Hotel wünscht noch einen angenehmen Tag.") print("Auf Wiedersehen!") break #break