check-in ist lauffähig implementiert, room_types enthält jetzt die Zimmer Objekte, Klasse Accounting eingefügt.
This commit is contained in:
parent
c830ff3eac
commit
ae13a52c95
153
client_test.py
153
client_test.py
|
@ -42,14 +42,14 @@ class Client():
|
||||||
months = ['Januar', 'Februar','März','April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']
|
months = ['Januar', 'Februar','März','April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']
|
||||||
all_clients=[]
|
all_clients=[]
|
||||||
clients = 0
|
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.name = name
|
||||||
self.surname = surname
|
self.surname = surname
|
||||||
self.client_num = client_num
|
self.client_num = client_num
|
||||||
self.room = None
|
self.room = None
|
||||||
self.period = period
|
self.period = period
|
||||||
self.key_num = 0
|
self.key_num = 0
|
||||||
self.bookings = 0
|
self.bookings = []
|
||||||
self.status = False
|
self.status = False
|
||||||
|
|
||||||
# Automatic status adjustment
|
# Automatic status adjustment
|
||||||
|
@ -58,14 +58,18 @@ class Client():
|
||||||
Client.clients += 1
|
Client.clients += 1
|
||||||
|
|
||||||
def check_in(self, room, key_num):
|
def check_in(self, room, key_num):
|
||||||
room_list[reference.index(room)].occupy(surname, self.period)
|
room_list[reference.index(room)].occupy(self.surname, self.period)
|
||||||
num_ = "key_" + str(key_num) + ".hand_out_key(" + str(key_num) + "," + "'" + str(surname) + "')"
|
num_ = "key_" + str(key_num) + ".hand_out_key(" + str(key_num) + "," + "'" + str(self.surname) + "')"
|
||||||
try:
|
try:
|
||||||
exec(num_)
|
exec(num_)
|
||||||
self.key_num = key_num
|
self.key_num = key_num
|
||||||
except:
|
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
|
def change_room(self, surname, new_room, key_num = 0): # Room add period
|
||||||
room_list[reference.index(self.room)].free()
|
room_list[reference.index(self.room)].free()
|
||||||
|
@ -95,7 +99,6 @@ class Client():
|
||||||
|
|
||||||
stay_period.append(num_string)
|
stay_period.append(num_string)
|
||||||
|
|
||||||
print(stay_period)
|
|
||||||
stay_period = tuple(stay_period)
|
stay_period = tuple(stay_period)
|
||||||
# Same month
|
# Same month
|
||||||
if stay_period[1] == stay_period[3]:
|
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 = Client("David", "Gebert", "w43", "Suite", "01,02,03,03", 22, (51,61,77), False)
|
||||||
w43.period_print()
|
w43.period_print()
|
||||||
|
|
||||||
|
|
||||||
#----------------CLASS--ROOM------------------------------------------
|
#----------------CLASS--ROOM------------------------------------------
|
||||||
|
|
||||||
''' Implementierung der Klasse Zimmer '''
|
''' Implementierung der Klasse Zimmer '''
|
||||||
|
@ -185,25 +189,142 @@ class Room:
|
||||||
|
|
||||||
if action != None:
|
if action != None:
|
||||||
if action == "Nummer":
|
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 action == "Gast":
|
||||||
if dic_["Gast"] != None:
|
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:
|
else:
|
||||||
print("Das Zimmer" + str(self) + "ist im Moment nicht belegt.")
|
print("Das Zimmer" + str(self.number) + "ist im Moment nicht belegt.")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for i in dic_:
|
for i in dic_:
|
||||||
print(i.ljust(16), ": ", dic_[i])
|
print(i.ljust(16), ": ", dic_[i])
|
||||||
|
|
||||||
# Generates all the rooms
|
# Generates all the rooms
|
||||||
# nr.10-"Single", nr.20-"Double", nr.30-"Suite", nr.40-"Panorama-Suite"
|
# nr.10-"Single", nr.20-"Double", nr.30-"Suite", nr.40-"Panorama_Suite"
|
||||||
reference = ["Single", "Double", "Suite", "Panorama-Suite"]
|
reference = ["Single", "Double", "Suite", "Panorama_Suite"]
|
||||||
room_types = [["Single", 10], ["Double", 20], ["Suite", 30], ["Panorama-Suite", 40]]
|
room_types = [["Single", 10], ["Double", 20], ["Suite", 30], ["Panorama_Suite", 40]]
|
||||||
room_list = []
|
room_list = []
|
||||||
for i in room_types:
|
for i in room_types:
|
||||||
tmp = '''i[0] = Room(i[1])
|
tmp = i[0] + " = Room(" + str(i[1]) + ")"
|
||||||
room_list.append(i[0])'''
|
|
||||||
exec(tmp)
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user