-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsarmadi_bakers.py
404 lines (347 loc) · 19.8 KB
/
sarmadi_bakers.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
import json
import random
import datetime
lucky_draw_limit = 4
print("")
print("\t|======| /\ |====| |\ /| /\ |===) ===== ")
print("\t| / \ | | | \ / | / \ | ) | ")
print("\t|======| /====\ |====| | \ / | /====\ | ) | ")
print("\t | / \ | \ | \ / | / \ | ) | ")
print("\t|======| / \ | \_ | \/ | / \ |===) ===== ")
print()
print("\t\t|=====) /\ | / |===== |====| |======| ")
print("\t\t| | / \ | / | | | | ")
print("\t\t|=====) /====\ |_/ |===== |====| |======| ")
print("\t\t| | / \ | \ | | \ | ")
print("\t\t|=====) / \ | \_ |===== | \_ |======| ")
print()
print("\t\t\t ( WE TIP-TOP FOODIES )")
def dob_check(x): # FUNCTION TO CHECKS VALIDITY OF DATE OF BIRTH
while True:
if len(x) == 10 and x[0:2].isdigit and (int(x[0:2]) in range(1, 32)) and x[2] == "/" and x[3:5].isdigit() and (
int(x[3:5]) in range(1, 13)) and x[5] == "/" and x[6:10].isdigit() and (
int(x[6:10]) in range(1900, 2020)):
return x
elif len(x) == 10 and (int(x[0:2]) not in range(1, 32)) and x[0:2].isdigit and x[2] == "/" and x[
3:5].isdigit() and (
int(x[3:5]) in range(1, 13)) and x[5] == "/" and x[6:10].isdigit() and (
int(x[6:10]) in range(1900, 2020)) and len(x) == 10:
x = input("Invalid Day. Enter A Valid Date: ")
elif len(x) == 10 and (int(x[3:5]) not in range(1, 13)) and x[0:2].isdigit and (int(x[0:2]) in range(1, 32)) and \
x[2] == "/" and x[3:5].isdigit() and x[5] == "/" and x[6:10].isdigit() and (
int(x[6:10]) in range(1900, 2020)) and len(x) == 10:
x = input("Invalid Month. Enter A Valid Date: ")
elif len(x) == 10 and (int(x[6:10]) not in range(1900, 2020)) and x[0:2].isdigit and (
int(x[0:2]) in range(1, 32)) and x[2] == "/" and x[3:5].isdigit() and (int(x[3:5]) in range(1, 13)) and \
x[5] == "/" and x[6:10].isdigit() and len(x) == 10:
x = input("This Year Is Not Available. Enter A Valid Date: ")
else:
x = input("Invalid Entry. Enter A Valid Date: ")
def mobile_no_check(x): # FUNCTION TO CHECK VALIDITY OF MOBILE NUMBER
while True:
if x[0:4].isdigit() and x[5:13].isdigit() and x[0:2] == "03" and len(x) == 12 and x[4] == "-":
return x
else:
x = input("Invalid Entry. Enter Mobile No# in formate '03XX-XXXXXXX' : ")
def cnic_check(x): # FUNCTION TO CHECK VALIDITY OF CNIC
while True:
if len(x) == 15 and x[5] == "-" and (x[0:5].isdigit()) and x[6:13].isdigit() and x[13] == "-" and x[14].isdigit():
return x
else:
x = input("Invalid Entry. Enter CNIC in this Format 'XXXXX-XXXXXXX-X': ")
def main_end_check(x): # TO CHECK MAIN AND END VALID COMMAND
main_end_check_list = ["#", "*", "b", "B"]
while True:
if x in main_end_check_list:
return x
else:
x = input("Invalid Entry. Kindly Reply in '#' OR '*' : ")
def yes_no_check(x): # CHECK FOR YES NO COMMAND
while True:
yes_no_check_list = ["y", "yes", "no", "n"]
if x in yes_no_check_list:
return x
else:
x = input("Invalid Entry. Kindly Reply in 'yes' or 'no': ")
def digit(x): # FUNCTION CHECK FOR DIGIT ENTRY
while True:
if x.replace(".", " ").lstrip("+,-").isdigit():
return x
else:
x = input("Invalid Entry. Kindly Enter in Numbers: ")
repeat = "y"
while repeat == "y" or repeat == "yes": # THIS LOOP IS TO REPEAT THE CODE
name = input("\nDear User Kindly Enter your name: ")
address = input("Kindly Enter Your Address: ")
while True: # THIS LOOP IS FOR THE MAIN MENU
with open("data.json") as jsonFile:
project_data = json.load(jsonFile)
jsonFile.close()
print(
"\n\nPress '1' To Buy Something From Stock \nPress '2' To Apply For Job in SARMADI BAKERS \nPress '3' To "
"Apply For Lucky Draw of Umrah Ticket")
def choice(x): # FUNCTION FOR CHECK PURPOSE
while True:
if x == "1" or x == "2" or x == "3":
return x
else:
x = input("Kindly Enter a Valid Choice: ")
initial_choice = int(choice(input("Enter Your Choice: ")))
if initial_choice == 1:
# RANDOMLY CHOOSE OUR EMPLOY
employ = random.choice(project_data["employees"])
# LIST FOR CHECK PURPOSE OF ITEM SELECTION
item_selection_check_list = ["e"]
# LIST FOR CHECK PURPOSE TO REMOVE ITEMS
remove_check_list = ["e", "b"]
products = project_data["products"]
print("\n")
sold_items = [] # LIST FOR STORING SOLD ITEMS
remove_items = [] # LIST FOR STORING ITEM NUMBERS THAT WE WANNA REMOVE
remove = "b"
while remove == "b": # LOOP FOR MOVING BACK
sold_items_prices = [] # LIST FOR STORING PRICES OF SOLD ITEMS
total_price = 0 # VARIABLE FOR STORING TOTAL BILL
print("\nLIST OF AVAILABLE PRODUCTS :")
print("----------------------------")
# THESE BELOW LINES OF CODE IS DISPLAYING PRODUCTS IN LIST
for k in range(len(products)):
item_selection_check_list.append(str(k))
key_tuple = tuple(products.keys())
value_tuple = tuple(products.values())
print('{:3}) {:16}=\t{:6}'.format(k, key_tuple[k], value_tuple[k]))
while True: # THIS LOOP IS FOR CHECK PURPOSE AND FOR STORING USER CHOICES REGARDING PRODUCT SELLING
item_selection = input("\nChoose Item or Enter 'e' to Exit: ").lower()
if item_selection in item_selection_check_list:
if item_selection == "e":
break
else:
bought = key_tuple[int(item_selection)]
sold_items.append(bought)
else:
print("Invalid Entry. This Choice is Not Available")
# THIS LOOP IS FOR STORING SOLD ITEM PRICES
for items_nos in range(len(sold_items)):
price = str(products[sold_items[items_nos]])
sold_items_prices.append(price)
# THESE BELOW LINES ARE DISPLAYING SELECTED ITEMS IN LIST
print("\nLIST OF CHOOSEN ITEMS:")
print("----------------------")
for l in range(len(sold_items)):
remove_check_list.append(str(l))
total_price = total_price + products[sold_items[l]]
print('{:3}) {:16}=\t{:6}'.format(l, sold_items[l], sold_items_prices[l]))
print("------------------------------")
print('{:22}=\t{}'.format("Total", total_price))
while True: # THIS LOOP IS STORING THE ENTRIES THAT WE WANNA REMOVE
remove = input("\nChoose Item To Remove or Type 'e' To End or type 'b' To Go Back: ").lower()
if remove in remove_check_list:
if remove == "e" or remove == "b":
break
else:
remove_items.append(int(remove))
else:
print("Invalid Entry. This Choice is Not Available")
if remove == "b":
continue
# THESE BELOW LINES OF CODE IS DISPLAY THE FINAL RECEIPT
print("\nFINAL RECEIPT :")
print("-----------------")
for y in range(len(sold_items)):
if y in remove_items:
print('{:3}) {:16}=\t{:6} {}'.format(y, sold_items[y], sold_items_prices[y], "REMOVED"))
total_price = total_price - products[sold_items[y]]
else:
print('{:3}) {:16}=\t{:6}'.format(y, sold_items[y], sold_items_prices[y]))
print("------------------------------")
print('{:22}=\t{}'.format("Total", total_price))
time = (datetime.datetime.today() + datetime.timedelta(hours=0.5)).strftime("%I:%M %p") # TO DISPLAY 30 MINS AFTER TIME
if total_price == 0:
final = main_end_check(input("\nType '#' To Move To Main Menu OR Type '*' To End: "))
if final == "#":
continue
elif final == "*":
break
else:
print("\nDear ", name, ", you will have to pay the bill of Rs:", total_price, " to ", employ,
" he will be at: ", address, " with your products uptill ", time)
final = main_end_check(input("\nType '#' To Move To Main Menu OR Type '*' To End: "))
if final == "#":
continue
elif final == "*":
break
if initial_choice == 2:
jobs = ["Chef", "Retailer", "Promoter", "Security Guard", "Sanitary Inspector", "Food Inspector",
"Emergency Dealer", "Cash Manager"]
print("\nLIST OF AVAILABLE JOBS:")
print("-----------------------")
job_selection_check_list = [] # LIST FOR CHECK PURPOSE OF JOB SELECTION
for i in range(len(jobs)): # LOOP FOR DISPLAYING JOBS IN PROPER LIST
print('{:3}) {}'.format(i, jobs[i]))
job_selection_check_list.append(str(i))
apply = input("\nChoose The Job You Want To Apply For: ")
while True: # LOOP FOR CHECK PURPOSE
if apply in job_selection_check_list:
break
else:
apply = input("This Choice Is Not Available. Kindly Enter A Valid Choice: ")
# BELOW LINES OF CODE ARE JOB CONDITIONS
if jobs[int(apply)] == "Chef":
degree = yes_no_check(input("Have you got the degree of Culinary Arts: ").lower())
if degree == "yes":
print("\nDear ", name,
", kindly come to our office on Monday at 10:00 AM, CEO Muhammad Sarmad and Manager Waqas will conduct a short interview")
if degree == "no":
print("\nDear ", name, ", You should have the degree of Culinary Arts if you want this Job")
elif jobs[int(apply)] == "Retailer":
degree = yes_no_check(input("Would you have a Good English Speaking and Communication Skills: ").lower())
if degree == "yes":
print("\nDear ", name,
", kindly come to our office on Monday at 10:00 AM, CEO Muhammad Sarmad and Manager Waqas "
"will conduct a short interview")
if degree == "no":
print("\nDear ", name,
", You should have a Good English Speaking and Communication Skills if you want this Job")
elif jobs[int(apply)] == "Promotor":
degree = yes_no_check(input("Would you have a Degree in Marketing: ").lower())
if degree == "yes":
print("\nDear ", name,
", kindly come to our office on Monday at 10:00 AM, CEO Muhammad Sarmad and Manager Waqas "
"will conduct a short interview")
if degree == "no":
print("\nDear ", name, ", You should have a Degree in Marketing if you want this Job")
elif jobs[int(apply)] == "Security Guard":
height = int(digit(input("Kindly Enter your height in Centimeters: ")))
age = int(digit(input("Kindly Enter your age in Years: ")))
if height < 178 and (age in range(25, 46)):
print("\nDear ", name, ", You are short-heighted for this job")
elif height > 187 and (age in range(25, 46)):
print("\nDear ", name, ", You are over-heighted for this job")
elif age < 25 and (height in range(178, 188)):
print("\nDear ", name, ", You are below age for this job")
elif age > 45 and (height in range(178, 188)):
print("\nDear ", name, ", You are over age for this job")
elif height < 178 and age < 25:
print("\nDear ", name,
", You are short-heighted and Below age for this job")
elif height < 178 and age > 45:
print("\nDear ", name,
", You are short-heighted and over age for this job")
elif height > 187 and age < 25:
print("\nDear ", name,
", You are over-heighted and Below age for this job")
elif height > 187 and age > 45:
print("\nDear ", name,
", You are over-heighted and over age for this job")
else:
print("\nCome to our office on Monday at 10:00 AM to take your Uniform")
elif jobs[int(apply)] == "Sanitary Inspector":
degree = yes_no_check(input("Would you have a Diploma in Sanitary Inspector's course: ").lower())
if degree == "yes":
print("\nDear ", name,
", kindly come to our office on Monday at 10:00 AM, CEO Muhammad Sarmad and Manager Waqas will conduct a short interview")
if degree == "no":
print("\nDear ", name,
", You should have a Diploma in Sanitary Inspector's course if you want this Job")
elif jobs[int(apply)] == "Food Inspector":
degree = yes_no_check(input("Would you have a Food Processing Degree: ").lower())
if degree == "yes":
print("\nDear ", name,
", kindly come to our office on Monday at 10:00 AM, CEO Muhammad Sarmad and Manager Waqas will conduct a short interview")
if degree == "no":
print("\nDear ", name, ", You should have a Food Processing Degree if you want this Job")
elif jobs[int(apply)] == "Emergency Dealer":
degree = yes_no_check(input("Would you have a complete Knowledge of First Aid: ").lower())
if degree == "yes":
print("\nDear ", name,
", kindly come to our office on Monday at 10:00 AM, CEO Muhammad Sarmad and Manager Waqas will conduct a short interview")
if degree == "no":
print("\nDear ", name, ", You should have a complete Knowledge of First Aid if you want this Job")
elif jobs[int(apply)] == "Cash Manager":
degree = yes_no_check(input("Would you have a Degree in Accounting and Finance: ").lower())
if degree == "yes":
print("\nDear ", name,
", kindly come to our office on Monday at 10:00 AM, CEO Muhammad Sarmad and Manager Waqas will conduct a short interview")
if degree == "no":
print("\nDear ", name, ", You should have a Degree in Accounting and Finance if you want this Job")
final = main_end_check(input("\nType '#' To Move To Main Menu OR Type '*' To End: "))
if final == "#":
continue
elif final == "*":
break
# UMRAH TICKET CODING
if initial_choice == 3:
try: # TO WRITE ONCE AND READ EVERYTIME PURPOSE
if len(project_data["lucky_draw_records"]) == lucky_draw_limit:
print("\n------ The Registration Is Over ------")
lucky_number = random.randint(0, lucky_draw_limit)
try:
lucky_number = project_data["lucky_number"]
except:
project_data["lucky_number"] = str(lucky_number)
# save data
with open("data.json", "w+") as jsonFile:
json.dump(project_data, jsonFile, indent=4)
jsonFile.close()
# THESE BELOW LINES ARE TO ANNOUNCE THE TICKET WINNER
print("\nTHE WINNER OF UMRAH TICKET IS :\n")
print('{:22}| {:16}| {:16}| {:30}| {}'.format(
project_data["lucky_draw_records"][int(
lucky_number)]["name"],
project_data["lucky_draw_records"][int(
lucky_number)]["cnic"],
project_data["lucky_draw_records"][int(
lucky_number)]["mobile"],
project_data["lucky_draw_records"][int(
lucky_number)]["email"],
project_data["lucky_draw_records"][int(
lucky_number)]["dob"]
))
except:
print()
if len(project_data["lucky_draw_records"]) < lucky_draw_limit:
print("\n\nPress 1 To Apply For Umrah Ticket\nPress 2 To View The List of Appliers For Umrah Ticket")
umrah_ticket_check_list = ["1", "2"] # LIST FOR CHECK PURPOSE
choice = input("Kindly Choose One of These: ")
while True: # LOOP FOR CHECK PURPOSE
if choice in umrah_ticket_check_list:
break
else:
choice = input("Invalid Entry. Kindly Choose '1' or '2' : ")
# CODE FOR APPLYING FOR TICKET
if choice == "1":
cnic = cnic_check(input("Enter Your CNIC XXXXX-XXXXXXX-X: "))
mobile = mobile_no_check(input("Enter Your Mobile N0#: "))
email = input("Enter Your Email Address: ")
dob = dob_check(input("Enter Your Date of Birth dd/mm/yyyy: "))
# add data new
project_data["lucky_draw_records"].append({
"name": name,
"cnic": cnic,
"mobile": mobile,
"email": email,
"dob": dob
})
# save data new
with open("data.json", "w+") as jsonFile:
json.dump(project_data, jsonFile, indent=4)
jsonFile.close()
# CODE FOR DISPLAYING APPLIERS IN PROPER LIST
if choice == "2":
if len(project_data["lucky_draw_records"]) > 0:
print('\n {:22}| {:16}| {:16}| {:30}| {}'.format("NAME", "CNIC", "MOBILE NO#", "EMAIL ADDRESS", "DATE OF BIRTH"))
for i in range(110):
print("-", end="")
print("\n")
for index, record in enumerate(project_data["lucky_draw_records"]):
print('{:2}) {:22}| {:16}| {:16}| {:30}| {}'.format(
index, record["name"], record["cnic"], record["mobile"], record["email"], record["dob"]))
else:
print("\nRECORD NOT AVAILABLE")
# CONDITION TO GO TO MAIN OR TO END
final = main_end_check(input("\nType '#' To Move To Main Menu OR Type '*' To End: "))
if final == "#":
continue
elif final == "*":
break
repeat = yes_no_check(input("\nDo You Want To Run The Code Again: ").lower())