-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
41 lines (38 loc) · 1.73 KB
/
Copy pathmain.py
File metadata and controls
41 lines (38 loc) · 1.73 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
from auth import setup, register, login
from transport import book_ticket, ticket_history, buy_pass, view_passes, top_up_wallet, view_profile
from utils import clear, line
def dashboard(u):
while True:
clear(); line()
print(f" SMART FARE | Hello, {u.upper()}"); line()
print(" [1] Book a Ticket\n [2] My Ticket History\n [3] Buy a Bus Pass")
print(" [4] View My Passes\n [5] Payment / Top-Up Wallet\n [6] My Profile\n [0] Logout"); line()
ch = input(" Your choice: ").strip()
actions = {"1": book_ticket, "2": ticket_history, "3": buy_pass, "4": view_passes, "5": top_up_wallet, "6": view_profile}
if ch == "0": print(f"\nGoodbye, {u}! Travel safe!"); break
elif ch in actions:
try: actions[ch](u)
except Exception as e: print("Something went wrong:", e)
else: print("Invalid choice.")
input("\nPress Enter to continue ...")
def main():
setup()
while True:
clear(); line()
print(" SMART FARE\n Bus Ticket Management System"); line()
print(" [1] Login\n [2] Create Account\n [0] Exit"); line()
ch = input(" Your choice: ").strip()
try:
if ch == "1":
u = login()
if u: dashboard(u)
elif ch == "2":
u = register()
if u: dashboard(u)
elif ch == "0": print("\nThank you for using Smart Fare! Goodbye!\n"); break
else: print("Invalid choice.")
except KeyboardInterrupt: print("\n\nApp closed. Goodbye!"); break
except Exception as e: print("Something went wrong:", e)
input("\nPress Enter to continue ...")
if __name__ == "__main__":
main()