-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPython_ExamProject.py
723 lines (662 loc) · 28 KB
/
Python_ExamProject.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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
import os
clear = lambda: os.system('cls')
def s():
print()
with open("totalpayment.txt","w") as tp:
tp.write("Receipt :")
with open("gasolines.txt","w") as gasolines:
gasolines.write("AI92 - 1.0 dollar,")
gasolines.write("AI95 - 1.4 dollar,")
gasolines.write("Disel - 0.8 dollar")
with open("foods.txt","w") as foods:
foods.write("Hamburger - 1.5 dollar,")
foods.write("Sandwich - 2 dollar,")
foods.write("Cheeseburger - 1.5 dollar,")
foods.write("Coca-Cola - 0.7 dollar,")
foods.write("Fanta - 0.7 dollar")
with open("admins.txt","w") as ad:
ad.write("Admin - 12345678")
def welcome():
print("MAIN MENU")
print("\nWelcome to the Gas Station.")
guestOrAdmin = input("Are you Guest (1) or Admin (2) : ")
while True:
if (guestOrAdmin == "1"):
clear()
choosePurchaseMethod()
break
elif (guestOrAdmin == "2"):
clear()
adminCheck()
break
else:
guestOrAdmin = input("Please enter 1 (Guest) or 2 (Admin) : ")
def mainMenu():
welcome()
def choosePurchaseMethod():
s()
choiceOfPurchase = int(input("Choose purchase method\nWith liters (1) | With money (2) : "))
while True:
if (choiceOfPurchase == 1):
chooseTypeOfGasolineLiter()
break
elif (choiceOfPurchase == 2):
chooseTypeOfGasolineMoney()
break
else:
choiceOfPurchase = int(input("Please, enter 1 or 2 : "))
def chooseTypeOfGasolineLiter():
clear()
with open("gasolines.txt","r") as gasolines:
for gasolines in gasolines.readlines():
g = gasolines
gasolineList = g.split(",")
showInfoOfGasolines = [gasolineList[0],gasolineList[1],gasolineList[2]]
s()
for x in showInfoOfGasolines:
print(x)
choiceOfGasoline = int(input("\nWhich gasoline do you want to buy ?\nAI92 (1) | AI95 (2) | Disel (3) : "))
while True:
if (choiceOfGasoline == 1 or choiceOfGasoline == 2 or choiceOfGasoline == 3):
break
else:
choiceOfGasoline = int(input("Please, enter 1 (AI92) or 2 (AI95) or 3 (Disel) : "))
clear()
litersOfGasoline = float(input("\nHow many liters of gasoline will you get ?\n- "))
with open("gasolines.txt","r") as gasolines:
for gasolines in gasolines.readlines():
g = gasolines
split = g.split(",")
AI92value = split[0].split(" - ")[1].split(" ")[0].strip()
AI95value = split[1].split(" - ")[1].split(" ")[0].strip()
Diselvalue = split[2].split(" - ")[1].split(" ")[0].strip()
if (choiceOfGasoline == 1):
clear()
priceAI92 = litersOfGasoline * float(AI92value)
if (priceAI92 == int(priceAI92)):
print("\nAmount to pay for gasoline is \b",int(priceAI92),"dollars.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : AI92.")
tp.write("\n")
tp.write("Price of gasoline : 1$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(litersOfGasoline))
tp.write(" liters.")
tp.write("\n")
tp.write("\n")
tp.write("Amount to pay for gasoline is ")
tp.write(str(int(priceAI92)))
tp.write(" dollars.")
doYouWantFood()
else:
print("\nAmount to pay for gasoline is \b",int(priceAI92),"dollars",int(100 * (priceAI92 - int(priceAI92))),"cents.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : AI92.")
tp.write("\n")
tp.write("Price of gasoline : 1$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(litersOfGasoline))
tp.write(" liters.")
tp.write("\n")
tp.write("\n")
tp.write("Amount to pay for gasoline is ")
tp.write(str(int(priceAI92)))
tp.write(" dollar ")
tp.write(str(int(100 * (priceAI92 - int(priceAI92)))))
tp.write(" cents.")
doYouWantFood()
elif (choiceOfGasoline == 2):
priceAI95 = litersOfGasoline * float(AI95value)
if (priceAI95 == int(priceAI95)):
print("\nAmount to pay for gasoline is \b",int(priceAI95),"dollars.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : AI95.")
tp.write("\n")
tp.write("Price of gasoline : 1.4$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(litersOfGasoline))
tp.write(" liters.")
tp.write("\n")
tp.write("\n")
tp.write("Amount to pay for gasoline is ")
tp.write(str(int(priceAI95)))
tp.write(" dollars.")
doYouWantFood()
else:
print("\nAmount to pay for gasoline is \b",int(priceAI95),"dollars",int(100 * (priceAI95 - int(priceAI95))),"cents.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : AI95.")
tp.write("\n")
tp.write("Price of gasoline : 1.4$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(litersOfGasoline))
tp.write(" liters.")
tp.write("\n")
tp.write("\n")
tp.write("Amount to pay for gasoline is ")
tp.write(str(int(priceAI95)))
tp.write(" dollar ")
tp.write(str(int(100 * (priceAI95 - int(priceAI95)))))
tp.write(" cents.")
doYouWantFood()
elif (choiceOfGasoline == 3):
priceDisel = litersOfGasoline * float(Diselvalue)
if (priceDisel == int(priceDisel)):
print("\nAmount to pay for gasoline is \b",int(priceDisel),"dollars.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : Disel.")
tp.write("\n")
tp.write("Price of gasoline : 0.8$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(litersOfGasoline))
tp.write(" liters.")
tp.write("\n")
tp.write("\n")
tp.write("Amount to pay for gasoline is ")
tp.write(str(int(priceDisel)))
tp.write(" dollars.")
doYouWantFood()
else:
print("\nAmount to pay for gasoline is \b",int(priceDisel),"dollars",int(100 * (priceDisel - int(priceDisel))),"cents.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : Disel.")
tp.write("\n")
tp.write("Price of gasoline : 0.8$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(litersOfGasoline))
tp.write(" liters.")
tp.write("\n")
tp.write("\n")
tp.write("Amount to pay for gasoline is ")
tp.write(str(int(priceDisel)))
tp.write(" dollar ")
tp.write(str(int(100 * (priceDisel - int(priceDisel)))))
tp.write(" cents.")
doYouWantFood()
def chooseTypeOfGasolineMoney():
clear()
with open("gasolines.txt","r") as gasolines:
for gasolines in gasolines.readlines():
g = gasolines
gasolineList = g.split(",")
showInfoOfGasolines = [gasolineList[0],gasolineList[1],gasolineList[2]]
s()
for x in showInfoOfGasolines:
print(x)
choiceOfGasoline = int(input("\nWhich gasoline do you want to buy ?\nAI92 (1) | AI95 (2) | Disel (3) : "))
while True:
if (choiceOfGasoline == 1 or choiceOfGasoline == 2 or choiceOfGasoline == 3):
break
else:
choiceOfGasoline = int(input("Please, enter 1 (AI92) or 2 (AI95) or 3 (Disel) : "))
clear()
dollarsOfGasoline = float(input("\nEnter amount (dollar)?\n- "))
with open("gasolines.txt","r") as gasolines:
for gasolines in gasolines.readlines():
g = gasolines
split = g.split(",")
AI92value = split[0].split(" - ")[1].split(" ")[0].strip()
AI95value = split[1].split(" - ")[1].split(" ")[0].strip()
Diselvalue = split[2].split(" - ")[1].split(" ")[0].strip()
if (choiceOfGasoline == 1):
priceAI92 = dollarsOfGasoline / float(AI92value)
if (priceAI92 == int(priceAI92)):
print("\nAmount of gasoline is \b",int(priceAI92),"liters.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : AI92.")
tp.write("\n")
tp.write("Price of gasoline : 1$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(dollarsOfGasoline))
tp.write(" dollars of AI92.")
tp.write("\n")
tp.write("\n")
tp.write("Amount of gasoline is ")
tp.write(str(int(priceAI92)))
tp.write(" liters.")
doYouWantFood()
else:
print("\nAmount of gasoline is \b",int(priceAI92),"liters",int(100 * (priceAI92 - int(priceAI92))),"milliliters.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : AI92.")
tp.write("\n")
tp.write("Price of gasoline : 1$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(dollarsOfGasoline))
tp.write(" dollars of AI92.")
tp.write("\n")
tp.write("\n")
tp.write("Amount of gasoline is ")
tp.write(str(int(priceAI92)))
tp.write(" liters ")
tp.write(str(int(100 * (priceAI92 - int(priceAI92)))))
tp.write(" milliliters.")
doYouWantFood()
elif (choiceOfGasoline == 2):
priceAI95 = dollarsOfGasoline / float(AI95value)
if (priceAI95 == int(priceAI95)):
print("\nAmount of gasoline is is \b",int(priceAI95),"liters.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : AI95.")
tp.write("\n")
tp.write("Price of gasoline : 1.4$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(dollarsOfGasoline))
tp.write(" dollars of AI95.")
tp.write("\n")
tp.write("\n")
tp.write("Amount of gasoline is ")
tp.write(str(int(priceAI95)))
tp.write(" liters.")
doYouWantFood()
else:
print("\nAmount of gasoline is \b",int(priceAI95),"liters",int(100 * (priceAI95 - int(priceAI95))),"milliliters.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : AI95.")
tp.write("\n")
tp.write("Price of gasoline : 1.4$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(dollarsOfGasoline))
tp.write(" dollars of AI95.")
tp.write("\n")
tp.write("\n")
tp.write("Amount of gasoline is ")
tp.write(str(int(priceAI95)))
tp.write(" liters ")
tp.write(str(int(100 * (priceAI95 - int(priceAI95)))))
tp.write(" milliliters.")
doYouWantFood()
elif (choiceOfGasoline == 3):
priceDisel = dollarsOfGasoline / float(Diselvalue)
if (priceDisel == int(priceDisel)):
print("\nAmount of gasoline is \b",int(priceDisel),"liters.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : Disel.")
tp.write("\n")
tp.write("Price of gasoline : 0.8$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(dollarsOfGasoline))
tp.write(" dollars of Disel.")
tp.write("\n")
tp.write("\n")
tp.write("Amount of gasoline is ")
tp.write(str(int(priceDisel)))
tp.write(" liters.")
doYouWantFood()
else:
print("\nAmount of gasoline is \b",int(priceDisel),"liters",int(100 * (priceDisel - int(priceDisel))),"milliliters.")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
tp.write("\n")
tp.write("Type of gasoline : Disel.")
tp.write("\n")
tp.write("Price of gasoline : 0.8$ per liter.")
tp.write("\n")
tp.write("Purchased : ")
tp.write(str(dollarsOfGasoline))
tp.write(" dollars of Disel.")
tp.write("\n")
tp.write("\n")
tp.write("Amount of gasoline is ")
tp.write(str(int(priceDisel)))
tp.write(" liters ")
tp.write(str(int(100 * (priceDisel - int(priceDisel)))))
tp.write(" milliliters.")
doYouWantFood()
def doYouWantFood():
with open("foods.txt","r") as foods:
for food in foods:
f = food
hamburgerValue = float(f.split(",")[0].split(" - ")[1].split(" ")[0])
sandwichValue = float(f.split(",")[1].split(" - ")[1].split(" ")[0])
cheeseburgerValue = float(f.split(",")[2].split(" - ")[1].split(" ")[0])
cocacolaValue = float(f.split(",")[3].split(" - ")[1].split(" ")[0])
fantaValue = float(f.split(",")[4].split(" - ")[1].split(" ")[0])
clear()
yesOrNo = input("\nDo you want to buy food ?\nYes (1) | No (2) : ").strip()
while True :
if (yesOrNo == "1"):
clear()
with open("foods.txt","r") as tp:
for x in tp.readlines():
a = x
foodList = a.split(",")
showInfoOfFoods = [foodList[0],foodList[1],foodList[2],foodList[3],foodList[4]]
s()
for x in showInfoOfFoods:
print(x)
s()
print("Please, enter number with commas (e.g 1,2,3,4,5).")
choiceOfFoodandDrinking = input("\nWhich food do you want to buy ?\nHamburger (1) | Cheeseburger (2) | Sandwich (3) | Coca-Cola (4) | Fanta (5) : ").split(",")
s()
clear()
s()
if ("1" in choiceOfFoodandDrinking):
numberOfHamburgers = int(input("How many hamburgers do you want ?\n- "))
else:
numberOfHamburgers = 0
if ("2" in choiceOfFoodandDrinking):
numberOfCheeseburgers = int(input("How many cheeseburgers do you want ?\n- "))
else:
numberOfCheeseburgers = 0
if ("3" in choiceOfFoodandDrinking):
numberOfSandwiches = int(input("How many sandwiches do you want ?\n- "))
else:
numberOfSandwiches = 0
if ("4" in choiceOfFoodandDrinking):
numberOfCocaColas = int(input("How many Coca-colas do you want ?\n- "))
else:
numberOfCocaColas = 0
if ("5" in choiceOfFoodandDrinking):
numberOfFantas = int(input("How many Fantas do you want ?\n- "))
else:
numberOfFantas = 0
s()
clear()
if (numberOfHamburgers != 0):
print("Number of hamburgers : ",numberOfHamburgers)
if (numberOfCheeseburgers != 0):
print("Number of cheeseburgers : ",numberOfCheeseburgers)
if (numberOfSandwiches != 0):
print("Number of sandwiches :",numberOfSandwiches)
if (numberOfCocaColas != 0):
print("Number of Coca-Colas : ",numberOfCocaColas)
if (numberOfFantas != 0):
print("Number of Fantas : ",numberOfFantas)
if ("4" not in choiceOfFoodandDrinking and "5" not in choiceOfFoodandDrinking):
s()
clear()
s()
drinking = input("Do you want something to drink ?\nYes (1) | No (2) : ")
while True:
if (drinking == "1"):
clear()
with open("foods.txt","r") as foods:
for food in foods:
f = food
s()
print(f.split(",")[3])
print(f.split(",")[4])
choiceOfDrinking = input("\nWhich drinking do you want to buy ?\nCoca-Cola (1) | Fanta (2) : ").split(",")
s()
if ("1" in choiceOfDrinking):
numberOfCocaColas = int(input("How many Coca-Colas do you want ?\n- "))
else:
numberOfCocaColas = 0
if ("2" in choiceOfDrinking):
numberOfFantas = int(input("How many Fantas do you want ?\n- "))
else:
numberOfFantas = 0
s()
if (numberOfHamburgers != 0):
print("Number of hamburgers : ",numberOfHamburgers)
if (numberOfCheeseburgers != 0):
print("Number of cheeseburgers : ",numberOfCheeseburgers)
if (numberOfSandwiches != 0):
print("Number of sandwiches :",numberOfSandwiches)
if (numberOfCocaColas != 0):
print("Number of Coca-Colas : ",numberOfCocaColas)
if (numberOfFantas != 0):
print("Number of Fantas : ",numberOfFantas)
break
elif (drinking == "2"):
break
else:
drinking = int(input("Please, enter 1 (Yes) or 2 (No) : "))
priceFoodsAndDrinkings = (hamburgerValue * numberOfHamburgers) + (cheeseburgerValue * numberOfCheeseburgers) + (sandwichValue * numberOfSandwiches) + (cocacolaValue * numberOfCocaColas) + (fantaValue * numberOfFantas)
clear()
print("\nThe total amount of goods is",priceFoodsAndDrinkings,"$")
doYouWantToConfirm = input("\nDo you want to confirm goods ?\nYes (1) | No (2) : ")
if (doYouWantToConfirm == "1"):
s()
clear()
print("You can take your receipt from \"totalpayment.txt\".")
with open("totalpayment.txt","a") as tp:
tp.write("\n")
if (numberOfHamburgers != 0):
tp.write("\n")
tp.write("Food name : Hamburger")
tp.write("\n")
tp.write("Number of purchased hamburgers is ")
tp.write(str(numberOfHamburgers))
if (numberOfCheeseburgers != 0):
tp.write("\n")
tp.write("Food name : Cheeseburger")
tp.write("\n")
tp.write("Number of purchased cheeseburgers is ")
tp.write(str(numberOfCheeseburgers))
if (numberOfSandwiches != 0):
tp.write("\n")
tp.write("Food name : Sandwich")
tp.write("\n")
tp.write("Number of purchased sandwiches is ")
tp.write(str(numberOfSandwiches))
if (numberOfCocaColas != 0):
tp.write("\n")
tp.write("Drinking name : Coca-cola")
tp.write("\n")
tp.write("Number of purchased Coca-Colas is ")
tp.write(str(numberOfCocaColas))
if (numberOfFantas != 0):
tp.write("\n")
tp.write("Drinking name : Fanta")
tp.write("\n")
tp.write("Number of purchased Fantas is ")
tp.write(str(numberOfFantas))
tp.write("\n")
tp.write("\n")
tp.write("Total amount of goods is ")
tp.write(str(priceFoodsAndDrinkings))
tp.write(" dollars.")
break
else:
print("\nYou can take your receipt for gasolines from \"totalpayment.txt\".")
break
elif (yesOrNo == "2"):
print("\nYou can take your receipt for gasolines from \"totalpayment.txt\".")
break
elif (yesOrNo != "1" and yesOrNo != "2"):
yesOrNo = input("Please, enter 1 (Yes) or 2 (No) : ").strip()
else:
yesOrNo = input("Please, enter 1 (Yes) or 2 (No) : ").strip()
def deleteGasolineByName(nameOfGasoline):
with open("gasolines.txt","r") as gasolines:
for gasolines in gasolines.readlines():
g = gasolines
gasolineList = g.split(",")
for x in gasolineList:
if (x.split(" - ")[0].strip().upper() == nameOfGasoline.upper()):
gasolineList.remove(x)
with open("gasolines.txt","w") as gasolinesFile:
for z in gasolineList:
gasolinesFile.write(z)
gasolinesFile.write(",")
clear()
s()
print(nameOfGasoline,"was successfully deleted!")
s()
print("Here is the all gasolines.")
s()
for y in gasolineList:
print(y)
break
else:
print("\nThere is no gasoline with this name.")
def addGasolineByName(nameOfGasoline, priceOfGasoline):
with open("gasolines.txt","r") as gasolines:
for gasolines in gasolines.readlines():
g = gasolines
gasolineList = g.split(",")
newGasoline = nameOfGasoline + " - " + priceOfGasoline
gasolineList.append(newGasoline)
with open("gasolines.txt","w") as gasolinesFile:
for z in gasolineList:
if (len(z) > 0):
gasolinesFile.write(z)
gasolinesFile.write(",")
clear()
s()
print("Here is the all gasolines.")
s()
for x in gasolineList:
print(x)
def deleteFoodByName(nameOfFood):
with open("foods.txt","r") as tp:
for x in tp.readlines():
a = x
foodList = a.split(",")
foodexists = False
for x in foodList:
if (nameOfFood.upper() == x.split(" - ")[0].strip().upper()):
foodexists = True
foodList.remove(x)
with open("foods.txt","w") as foodFile:
for z in foodList:
foodFile.write(z)
foodFile.write(",")
clear()
s()
print(nameOfFood,"was successfully deleted!")
s()
print("Here is the all goods.")
s()
for y in foodList:
print(y)
if (not foodexists):
print("\nThere is no food with this name.")
def addFoodByName(nameOfFood, priceOfFood):
with open("foods.txt","r") as tp:
for x in tp.readlines():
a = x
foodList = a.split(",")
newFood = nameOfFood + " - " + priceOfFood + " dollar"
foodList.append(newFood)
with open("foods.txt","w") as foodFile:
for z in foodList:
if (len(z) > 0):
foodFile.write(z)
foodFile.write(",")
clear()
s()
print("Here is the all foods and drnkings.")
s()
for x in foodList:
print(x)
def permitToMakeChanges():
clear()
print("Welcome!")
select = input("\nPress 1 to see all gasolines\nPress 2 to see all foods\nPress 3 to delete gasoline\nPress 4 to add gasoline\nPress 5 to delete food or drinking\nPress 6 to add food or drinking\nPress 7 to go back\n-")
if (select == "1"):
clear()
s()
with open("gasolines.txt","r") as gasolines:
for gasolines in gasolines.readlines():
g = gasolines
gasolineList = g.split(",")
#showInfoOfGasolines =
#[gasolineList[0],gasolineList[1],gasolineList[2]]
for x in gasolineList:
print(x)
i = input("\n\nPress any key to continue . . . ")
permitToMakeChanges()
elif (select == "2"):
clear()
with open("foods.txt","r") as tp:
for x in tp.readlines():
a = x
foodList = a.split(",")
#showInfoOfFoods =
#[foodList[0],foodList[1],foodList[2],foodList[3],foodList[4]]
s()
for x in foodList:
print(x)
i = input("\n\nPress any key to continue . . . ")
permitToMakeChanges()
elif (select == "3"):
clear()
s()
nameOfGasoline = input("Enter the name of gasoline : ").upper()
deleteGasolineByName(nameOfGasoline)
i = input("\n\nPress any key to continue . . . ")
permitToMakeChanges()
elif (select == "4"):
clear()
s()
nameOfGasoline = input("Enter the name of gasoline : ")
priceOfGasoline = input("Enter the price of gasoline : ")
addGasolineByName(nameOfGasoline, priceOfGasoline)
i = input("\n\nPress any key to continue . . . ")
permitToMakeChanges()
elif (select == "5"):
clear()
s()
nameOfFood = input("Enter the name of food : ")
deleteFoodByName(nameOfFood)
i = input("\n\nPress any key to continue . . . ")
permitToMakeChanges()
elif (select == "6"):
clear()
s()
nameOfFood = input("Enter the name of food or drinking : ")
priceOfFood = input("Enter the price of food or drinking : ")
addFoodByName(nameOfFood, priceOfFood)
i = input("\n\nPress any key to continue . . . ")
permitToMakeChanges()
elif (select == "7"):
clear()
s()
return
else:
clear()
print("Plase, enter valid no!")
i = input("\n\nPress any key to continue . . . ")
permitToMakeChanges()
def adminCheck():
adminNameCheck = input("\nEnter your username : ").strip().title()
adminPasswordCheck = input("Enter your password : ").strip()
with open("admins.txt","r") as ad:
for x in ad:
adminInfo = x
adminName = adminInfo.split(" - ")[0]
adminPassword = adminInfo.split(" - ")[1]
if (adminNameCheck == adminName and adminPassword == adminPasswordCheck):
permitToMakeChanges()
else:
print("\nIncorrect password or username!")
i = input("\n\nPress any key to continue . . . ")
clear()
while True:
welcome()