-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
79 lines (71 loc) · 2.79 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
import datetime
from view import ask_for_meal, ask_for_discount, ask_for_filename, ask_for_service, ask_for_check_discount, \
ask_for_drink
from bill import Bill
def main():
"""
Main function for the Bill Management System.
It interacts with the user by presenting them with a menu of options for managing their bill.
The user can add meals, drinks, services, calculate the total bill amount, check available discounts,
apply discounts, save the bill to a file, and view the log.
:return: None
"""
bill = Bill()
action = "Start"
while action != "9":
action = input(
"\n--- Bill Management System ---\n"
"1. Add Meal\n"
"2. Add Drink\n"
"3. Add Service\n"
"4. Sum\n"
"5. Check Available Discount\n"
"6. Apply Discount\n"
"7. Save Bill\n"
"8. View Log\n"
"9. End\n"
"-----------------------------\n"
"Your choice (number): "
)
if action == "1":
name, price = ask_for_meal()
if name is None or price is None:
continue
bill.add_meal(name, price)
bill.log = action + f" - {datetime.datetime.now()}"
elif action == "2":
name, price = ask_for_drink()
if name is None or price is None:
continue
bill.add_drink(name, price)
bill.log = action + f" - {datetime.datetime.now()}"
elif action == "3":
name, price, guest_number = ask_for_service()
if name is None or price is None or guest_number is None:
continue
bill.add_services(name, price, guest_number)
bill.log = action + f" - {datetime.datetime.now()}"
elif action == "4":
total = bill.calculate()
print("Total bill amount:", total)
bill.log = action + f" - {datetime.datetime.now()}"
elif action == "5":
overall_sum, discount = ask_for_check_discount()
if overall_sum is None or discount is None:
continue
print(Bill.check_discount(overall_sum, discount))
bill.log = action + f" - {datetime.datetime.now()}"
elif action == "6":
discount = ask_for_discount()
if discount is None:
continue
print("Total bill amount with discount:", bill.calculate_with_discount(discount))
bill.log = action + f" - {datetime.datetime.now()}"
elif action == "7":
filename = ask_for_filename()
bill.print_to_file(filename)
bill.log = action + f" - {datetime.datetime.now()}"
elif action == "8":
print(bill.log)
if __name__ == '__main__':
main()