import math import os import sys import time #----------------CLASS---KEY------------------------------------------ class Key: how_many_keys = 0 # Initialisation of keys def __init__(self, keynumber): self.number = keynumber self.possessor = "Reception" #where are the keys def status_key(self, keynumber=None): return self.number, self.possessor def hand_out_key(self, keynumber, Guest): self.possessor = Guest def get_back_key(self, keynumber): self.possessor = "Reception" # 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------------------------------------------ class Client(): months = ['Januar', 'Februar','März','April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'] all_clients=[] clients = 0 def __init__(self, name: str, surname: str, client_num: str, room: str, period, key_num: int, bookings, status: 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 # Automatic status adjustment if len(self.bookings) >= 4: self.status = True Client.clients += 1 def check_in(self, room, key_num): print("Check In") while True: 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 break period = str(day_arrival) + "," +str(month_arrival) + "," + str(day_depature) + "," + str(month_depature) 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 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.") 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 change_room(self, surname, new_room, key_num = 0): # Room add period room_list[reference.index(self.room)].free() room_list[reference.index(new_room)].occupy(surname, self.period) num_ = "key_" + str(key_num) + ".hand_out_key(" + str(key_num) + "," + "'" + str(surname) + "')" try: exec(num_) self.key_num = key_num except: ("Schlüssel mit Daten nicht gefunden.") def name_change(self, name, surname): self.name = name self.surname = surname # 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 } 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): 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 = str(client_num) + ".check_in(" + "'" + str(room_name) + "'" + "," + str(key_num)+ ")" 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[3]): print("Das Zimmer", room_name, "ist in dem gewünschten Zeitraum frei.") if int(stay_period[3]) > int(stay_period_new[3]): print("Das Zimmer", room_name, " ist in dem gewünschten Zeitraum belegt.") if int(stay_period[3]) == int(stay_period_new[3]): if int(stay_period[2]) > int(stay_period_new[2]): print("Das Zimmer", room_name, " ist in dem gewünschten Zeitraum belegt.") if int(stay_period[2]) <= int(stay_period_new[2]): print("Das Zimmer", room_name, "ist in dem gewünschten Zeitraum belegt.") # room information def info(self, action = None): dic_ = {"Nummer" : self.number, "Gast" : self.resident, } if action != None: if action == "Nummer": print("Das Zimmer" + str(self.number) + "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 client_list: var = str(i) + ".client_bill_delete(" + "'" + bill_num + "'" + ")" #print(var) exec(var) var = str(i) + ".check_out()" #print(var) 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------------------------- client_list = [] 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)" print(c) client_list.append(client_num) return c k = add_client() exec(k) j = c0.check_in("Suite",31) exec(j) #print(c0.info()) clear() system_list = ["buchhaltung", "kundenverwaltung", "zimmerverfaltung", "schlüsselverwaltung", "dienstpläne", "b", "k", "z", "s", "d"] """-------------START-----INTERFACE--------------------""" 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) input("Start?") clear() #Intro play_obj = play_sound() #Logo Print ascii_print() print("WELCOME TO THE GRAND BUDAPEST HOTEL SYSTEM") input("Press enter to continue") clear() while True: print("Im System stehen Ihnen verschiedene Funktionen zur Verfügung.\n") while True: print(""" Buchhaltung Kundenverwaltung Zimmerverwaltung Schlüsselverwaltung Dienstpläne\n""") 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(""" Buchhaltung Kundenverwaltung Zimmerverwaltung Schküsselverwaltung Dienstpläne\n""") #"""-----------INTERFACE-----ACCOUNTING------------------""" if system == system_list[0]: #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 delete_ = "del " + bill_numb exec(delete_) # Delete bill in system bill_list.remove(bill_numb) # Delete bill at bill_list input() clear() continue if account == "abbrechen": clear() break #"""-----------INTERFACE-----CLIENT------------------""" if system == system_list[1]: #Client #bearbeitet ab hier clear() 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. Zimmer wechseln 5. Name ändern 6. Kunde auschecken (fehlt noch!) 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(client_list) while True: k = input("Über welchen Kunden wollen sie sich Information anzeigen lassen? ") if k in client_list: break else: print("Dieser Kunde ist leider nicht im System.") c = str(k) + ".info()" exec(c) clear() continue if client == "3": print("Kunde einchecken\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) print("Welchen Kunden möchten Sie einchecken?") print(client_list) while True: client = input() if client in client_list: break while True: print("Zimmer") room_ = input() if room_ in reference: break else: print("Dieses Zimmer ist in unserem Hotel leider nicht vorhanden.") #room_types = [["Single", 10], ["Double", 20], ["Suite", 30], ["Panorama_Suite", 40]] #for i in room_types: # if i[0] == room_: # key_num = i[1]+1 # print("Der Kunde erhält den Schlüssel", key_num) #check = str(client) + ".check_in(" + "'" + str(room_) + "'" + "," + str(key_num)+ ")" #print(check) #exec(check) clear() continue if client == "4": print("Zimmer wechseln\n") clear() if client == "5": print("Name ändern\n") clear() if client == "6": print("Kunde auschecken\n") clear() else: clear() break #"""-----------INTERFACE-----ROOM------------------""" if system == system_list[2]: #Room pass if system == system_list[3]: #Key pass if system == system_list[4]: #duty_roster pass if system == "beenden": clear() print("The Grand Budapest Hotel wünscht noch einen angenehmen Tag.") print("Auf Wiedersehen!") break #break