From ae13a52c95ba000eaa6a91ef1ea41b54d980783a Mon Sep 17 00:00:00 2001 From: adamercat Date: Tue, 2 Feb 2021 12:11:47 +0100 Subject: [PATCH] =?UTF-8?q?check-in=20ist=20lauff=C3=A4hig=20implementiert?= =?UTF-8?q?,=20room=5Ftypes=20enth=C3=A4lt=20jetzt=20die=20Zimmer=20Objekt?= =?UTF-8?q?e,=20Klasse=20Accounting=20eingef=C3=BCgt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client_test.py | 153 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 137 insertions(+), 16 deletions(-) diff --git a/client_test.py b/client_test.py index 6025d4c..f94bdcb 100644 --- a/client_test.py +++ b/client_test.py @@ -42,14 +42,14 @@ 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: int, room: str, period, key_num: int, bookings, status: bool): + 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 = 0 + self.bookings = [] self.status = False # Automatic status adjustment @@ -58,14 +58,18 @@ class Client(): Client.clients += 1 def check_in(self, room, key_num): - room_list[reference.index(room)].occupy(surname, self.period) - num_ = "key_" + str(key_num) + ".hand_out_key(" + str(key_num) + "," + "'" + str(surname) + "')" + room_list[reference.index(room)].occupy(self.surname, self.period) + 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.") - + ("Schlüssel mit Daten nicht gefunden.") + new_bill = add_bill(self.name, self.surname, self.client_num, room, self.period) + return new_bill + + def client_bill(self, bill_num): + self.bookings.append(str(bill_num)) def change_room(self, surname, new_room, key_num = 0): # Room add period room_list[reference.index(self.room)].free() @@ -95,7 +99,6 @@ class Client(): stay_period.append(num_string) - print(stay_period) stay_period = tuple(stay_period) # Same month if stay_period[1] == stay_period[3]: @@ -153,6 +156,7 @@ class Client(): w43 = Client("David", "Gebert", "w43", "Suite", "01,02,03,03", 22, (51,61,77), False) w43.period_print() + #----------------CLASS--ROOM------------------------------------------ ''' Implementierung der Klasse Zimmer ''' @@ -185,25 +189,142 @@ class Room: if action != None: if action == "Nummer": - print("Das Zimmer" + str(self) + "hat die Nummer" + dic_["Nummer"] + print("Das Zimmer" + str(self.number) + "hat die Nummer" + dic_["Nummer"]) if action == "Gast": if dic_["Gast"] != None: - print("Das Zimmer" + str(self) + "ist gerade vom Gast" + dic_["Gast"] + "belegt") + print("Das Zimmer" + str(self.number) + "ist gerade vom Gast" + dic_["Gast"] + "belegt") else: - print("Das Zimmer" + str(self) + "ist im Moment nicht belegt.") + 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]] +# 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(i[1]) -room_list.append(i[0])''' + tmp = i[0] + " = Room(" + str(i[1]) + ")" exec(tmp) -print(room_list) + tmp = "room_list.append(" + str(i[0]) + ")" + exec(tmp) + +print("roomlist", room_list) + +#----------------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]) + + 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 __del__(self): + print("Rechnung wurde storniert.") + + +#r43 = Accounting("Karl", "Otto", 16, 21,"2,3,4,5", "", False) +bill_list = [] + +#-------------YOU---ARE--LEAVING--CLASS--ACCOUNTING---------------------------- + + +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(): + while True: + k = input("Rechnungsnummer? ") + if k in bill_list: + break + c = str(k) + ".show_bill()" + exec(c) + +def delete_bill(): + input_ = input("Rechnungsnummer: ") + delete = "del " + input_ + exec(delete) + +k = w43.check_in("Suite",31) +exec(k)