-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
134 lines (109 loc) · 3.76 KB
/
main.py
File metadata and controls
134 lines (109 loc) · 3.76 KB
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
from useroperation import UserOperation
from productoperation import ProductOperation
from orderoperation import OrderOperation
from interface import InterfaceClass
def main():
user_operation = UserOperation()
product_operation = ProductOperation()
order_operation = OrderOperation()
interface = InterfaceClass()
while True:
interface.main_menu()
choice = input("Enter your choice: ")
if choice == "1":
# Login
username = input("Enter your username: ")
password = input("Enter your password: ")
success, user_role = user_operation.login(username, password)
if success:
if user_role == "admin":
admin_menu(interface, product_operation, user_operation, order_operation)
else:
customer_menu(interface, product_operation, user_operation, order_operation)
else:
interface.print_error_message("UserOperation.login", "Username or password incorrect")
elif choice == "2":
# Register
username = input("Enter a username: ")
password = input("Enter a password: ")
success = user_operation.register(username, password)
if success:
interface.print_message("Registration successful")
else:
interface.print_error_message("UserOperation.register", "Registration failed")
elif choice == "3":
# Quit
break
else:
interface.print_error_message("Main Menu", "Invalid choice")
def admin_menu(interface, product_operation, user_operation, order_operation):
while True:
interface.admin_menu()
choice = input("Enter your choice: ")
if choice == "1":
# Show products
page_number = int(input("Enter the page number: "))
product_list = product_operation.get_product_list(page_number)
interface.show_list("admin", "product", product_list)
elif choice == "2":
# TODO
# Add customers
# ...
elif choice == "3":
# TODO
# Show customers
# ...
elif choice == "4":
# TODO
# Show orders
# ...
elif choice == "5":
# TODO
# Generate test data
# ...
elif choice == "6":
# TODO
# Generate all statistical figures
# ...
elif choice == "7":
# TODO
# Delete all data
# ...
elif choice == "8":
# TODO
# Logout
break
else:
interface.print_error_message("Admin Menu", "Invalid choice")
def customer_menu(interface, product_operation, user_operation, order_operation):
while True:
interface.customer_menu()
choice = input("Enter your choice: ")
if choice == "1":
# TODO
# Show profile
...
elif choice == "2":
# TODO
# Update profile
# ...
elif choice == "3":
# TODO
# Show products
# ...
elif choice == "4":
# TODO
# Show history orders
# ...
elif choice == "5":
# TODO
# Generate all consumption figures
# ...
elif choice == "6":
# TODO
# Logout
break
else:
interface.print_error_message("Customer Menu", "Invalid choice")
if __name__ == "__main__":
main()