-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
293 lines (255 loc) · 7.59 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
import os
import pickle
print(
"----------------------------------------------------- 5 STAR HOTEL AND RESORTS -----------------------------------------------------------------")
u = list()
Delux = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Semi_Delux = (11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)
General = (26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45)
Joint_Room = (46, 47, 48, 49, 50, 46, 47, 48, 49, 50)
m = [9]
G = []
def chk_name():
while True:
print("\n")
name = input("ENTER GUEST NAME:")
a = name.isdigit()
if len(name) != 0 and a != True:
return name
break
else:
print("Invalid input! Please input a valid name")
print(" ")
def chk_add():
while True:
print("\n")
address = input("ENTER GUEST ADDRESS:")
a = address.isdigit()
if len(address) != 0 and a != True:
return address
break
else:
print("Invalid input ")
print(" ")
def chk_mo():
while True:
print("\n")
mobile_no = input("ENTER MOBILE/PHONE NO.:")
if mobile_no.isdigit() == True and len(mobile_no) != 0 and len(mobile_no) == 10:
return mobile_no
break
else:
print("invalid input ")
print(" ")
def chk_day():
while True:
print("\n")
no_of_days = input("ENTER NO. OF DAYS GUEST WANT TO STAY:")
a = no_of_days.isdigit()
if a == True and len(no_of_days) != 0:
return no_of_days
break
else:
print("invalid input ")
def chk_pay():
while True:
print("\n")
op = input("Enter guest's choice:")
a = op.isdigit()
if len(op) != 0 and a == True and (op == "1" or op == "2"):
op = int(op)
return op
break
else:
print("invalid input ")
class save:
price = 0
room = "0"
def __init__(self):
self.price = 0
self.name = " "
self.address = " "
self.no_of_days = 0
self.room = "0"
def enter(self):
self.name = chk_name()
self.address = chk_add()
self.mobile_no = chk_mo()
self.no_of_days = int(chk_day())
def tor(self):
print("1. Delux")
print("2. Semi-Delux")
print("3. General")
print("4. Joint Room")
while True:
ch = input("Enter guest's choice:")
a = ch.isdigit()
if len(ch) != 0 and a == True and (ch == "1" or ch == "2" or ch == "3" or ch == "4"):
break
else:
print("invalid input ")
ch = int(ch)
if ch == 1:
self.price = self.price + (2000 * self.no_of_days)
m[0] = 1
elif ch == 2:
self.price = self.price + (1500 * self.no_of_days)
m[0] = 2
elif ch == 3:
self.price = self.price + (1000 * self.no_of_days)
m[0] = 3
elif ch == 4:
self.price = self.price + (1700 * self.no_of_days)
m[0] = 4
else:
print("invalid choice")
def payment_option(self):
print("1. By cash")
print("2. By credit/debit card")
op = chk_pay()
if op == 1:
print("No discount.")
elif op == 2:
self.price = self.price - ((self.price * 10) / 100)
print("Discount of 10%.")
else:
print("Invalid option.")
def bill(self):
print("\n")
print("NAME-", self.name)
print("\n")
print("ADDRESS-", self.address)
print("\n")
print("MOBILE NO.-", self.mobile_no)
print("\n")
print("YOUR TOTAL BILL IS Rs.", self.price)
print("\n")
if m[0] == 1:
a = Delux
elif m[0] == 2:
a = Semi_Delux
elif m[0] == 3:
a = General
elif m[0] == 4:
a = Joint_Room
G = []
f2 = open("hotel.dat", "rb")
try:
while True:
s = pickle.load(f2)
k = s.room
G.append(k)
continue
except EOFError:
pass
for r in a:
if r not in G:
print(self.name, " - room", r, "is alloted to you")
self.room = r
break
else:
continue
self.room = r
print("\n")
print(" THANK YOU ")
print(" HOPE YOU WOULD ENJOY OUR SERVICE ")
while True:
print("\n")
print("1. Check in")
print("2. Show Guest List")
print("3. Check out")
print("4. Get info of guest")
print("5. EXIT")
k = input("Enter choice:")
if k == "1":
a = GUEST()
f = open("hotel.dat", "ab")
a.enter()
a.tor()
a.payment_option()
a.bill()
pickle.dump(a, f,protocol=2)
f.close()
elif k == "2":
f1 = open("hotel.dat", "rb")
print("NAME", "\t", "\t", "ROOM NO.")
try:
while True:
s = pickle.load(f1)
print(s.name, "\t", "\t", s.room)
except EOFError:
pass
f1.close()
elif k == "3":
print("\n")
while True:
a = input("ENTER ROOM NO.")
if len(a) != 0:
break
else:
print("no input found")
continue
v = int(a)
v = int(a)
f = open("hotel.dat", "rb")
f1 = open("hotel.dat", "ab")
n = 0
try:
while True:
s = pickle.load(f)
if s.room == v:
n = 1
name1=s.name
print(" ")
else:
pickle.dump(s, f1)
except EOFError:
if n == 0:
print("NO GUEST IN ROOM ", v)
elif n == 1:
print("THANK YOU",name1,"2 FOR VISTING US")
print("HOPE YOU LIKE OUR SERVICE")
print("\n")
pass
f.close()
f1.close()
os.remove("hotel.dat")
os.rename("hotel.dat", "hotel.dat")
elif k == "4":
f2 = open("hotel.dat", "rb")
while True:
v = input("ENTER ROOM NO.")
if len(v) != 0:
break
else:
print("no input found")
continue
v = int(v)
try:
n = 0
while True:
s = pickle.load(f2)
a = s.room
if v == a:
n = 1
print("NAME-", "\t", "\t", s.name)
print("\n")
print("ADDRESS-", "\t", s.address)
print("\n")
print("MOBILE NO.-", " ", s.mobile_no)
print("\n")
print("HIS TOTAL BILL IS Rs.", s.price)
elif EOFError:
if n == 0:
print("NO GUEST IN ROOM ", v)
else:
n = 0
continue
except EOFError:
pass
f2.close()
elif k == "5":
break
else:
print("invalid choice")
continue