change_room() Methode für Client implementiert, Methode info für Rooms angefangen

This commit is contained in:
adamercat 2021-02-02 10:12:23 +01:00
parent 8ceae79bc3
commit 43242e4d7e
1 changed files with 37 additions and 10 deletions

View File

@ -42,11 +42,11 @@ 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_num: int, period, key_num: int, bookings, status: bool):
def __init__(self, name: str, surname: str, client_num: int, room: str, period, key_num: int, bookings, status: bool):
self.name = name
self.surname = surname
self.client_num = client_num
self.room_num = room_num
self.room = room
self.period = period
self.key_num = key_num
self.bookings = bookings
@ -57,9 +57,9 @@ class Client():
self.status = True
Client.clients += 1
def change_room(self, surname, room_num = 0, key_num = 0): # Room add period
#self.room_num.free()
self.room_num = room_num
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_)
@ -117,7 +117,7 @@ class Client():
dic_ = {"Name" : self.name,
"Nachname" : self.surname,
"Kundennummer" : self.client_num,
"Zimmernummer" : self.room_num,
"Zimmer" : self.room,
"Aufenthaltsdauer": self.period,
"Schlüsselnummer" : self.key_num,
"Buchungen" : self.bookings,
@ -140,7 +140,7 @@ class Client():
w43 = Client("David", "Gebert", "w43", 0, "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()
#----------------CLASS--ROOM------------------------------------------
@ -149,7 +149,7 @@ w43.period_print()
class Room:
def __init__(self, room_number, Type, guest=None, period=None):
def __init__(self, room_number, guest=None, period=None):
self.number = room_number
self.occupied = False
self.resident = None
@ -166,7 +166,34 @@ class Room:
self.occupied = False
self.resident = None
self.period = None
# 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) + "hat die Nummer" + dic_["Nummer"]
if action == "Gast":
if dic_["Gast"] != None:
print("Das Zimmer" + str(self) + "ist gerade vom Gast" + dic_["Gast"] + "belegt")
else:
print("Das Zimmer" + str(self) + "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(i[1])
room_list.append(i[0])'''
exec(tmp)
print(room_list)