Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

# Bernard Ong Yuzhe/Edwin Neoh HanChern

# TP065754/TP065980

def home_page():
print("Welcome to APU Online Food Service (AOFS)!")
print("******************** Home Page ********************")
print(""" 1.Login \n 2.Register \n 3.Exit """)
while True:
try:
user_choice = int(input("Please enter your choice to proceed: "))
break
except ValueError:
print("Something else went wrong, please choose the three option had
given above, thank you.")
home_page()

if user_choice == 1:
print("Welcome member of APU, thanks for using AOFS")
print(""".\n.\n.""")
print("Proceeding to next page....................")
user_login_page()

elif user_choice == 2:
print("Welcome to Asia Pacific University, thanks for using AOFS,please
register before you order")
print(""".\n.\n.""")
print("Proceeding to next page....................")
user_register_page()

elif user_choice == 3:
print("Thank you, please come again, wish you have a great day!")

else:
print("Something else went wrong, please choose the three option had given
above, thank you.")
home_page()

# Register Page
def user_register_page():
print("""
********** APU Food Online Service (Register Page) **********
1. Registration Form
2. Back to Home Page
3. Exit
""")
while True:
try:
user_register_page_option = int(input("Please enter an option: "))
break
except ValueError:
print("Something else went wrong, please choose the three option had
given above, thank you.")
if user_register_page_option == 1:
print("Proceeding to Registration Form...")
user_registration_form()
elif user_register_page_option == 2:
print("Proceeding to the Home Page...")
home_page()
elif user_register_page_option == 3:
print("Thank you for using APU Food Online Service")
print("Have a Nice Day....... BYE BYE")
exit()
else:
print("Error selection.........")
print("Please try again ^_^")
user_register_page()

# user Registration Form

def user_registration_form():
print("Please fill in the registration form below")
user_tp = str(input("Enter your TP number: "))
user_name = str(input("Enter your name: "))
user_phone = str(input("Enter your phone number: "))

import re
while True:
user_password = input("Enter a password: ")
is_valid = False
if len(user_password) < 8 or len(user_password) > 15:
print("Password is not valid \n It total characters should be between 8
and 15")
continue
elif not re.search("[A-Z]", user_password):
print("Password is not valid \n It should contain at least one
uppercase letter.")
continue
elif not re.search("[a-z]", user_password):
print("Password is not valid \n It should contain at least one
lowercase letter.")
continue
elif not re.search("[1-9]", user_password):
print("Password is not valid \n It should contain at least one
number.")
continue
elif not re.search("[~!@#$%^&*]", user_password):
print("Password is not valid \n It should contain at least one
sysmbol.")
continue
else:
is_valid = True
break
if is_valid:
print("Password is valid")
print("""
Option:
1. Submit the registration form
2. Back to previous page
3. Exit
""")
while True:
try:
user_registration_form_option = int(input("Please select an option:
"))
datafile = open("user_data.txt", "a")
break
except ValueError:
print("Something else went wrong, please choose the three option
had given above, thank you.")
if user_registration_form_option == 1:
datafile.write(user_tp + "," + user_name + "," + user_password + "," +
user_phone + "\n")
datafile.close()
print("""
Registration Form Received !
Sending to staff.....
Redirecting back to Home Page
""")
home_page()
elif user_registration_form_option == 2:
print("Proceeding back to previous page......")
user_register_page()
elif user_registration_form_option == 3:
print("Thank you for using APU Food Online Service")
print("Have a Nice Day....... BYE BYE")
exit()
else:
print("Error option........")
print("Please try again ^_^")
user_registration_form()

# Log In Page

def user_login_page():
print("""
** APU Food Online Service (Login Page) **
__ Select An Account Type __
1. Customer Account
2. Admin Staff Account
3. Delivery Staff Account
4. Back to Home Page
5. Exit
""")
while True:
try:
user_login_page_option = int(input("Please enter an option: "))
break
except ValueError:
print("Something else went wrong, please choose the three option had
given above, thank you.")
if user_login_page_option == 1:
user_tp_num_cs = str(input("TP number: "))
user_password_cs = str(input("Password: "))
user_login_cs(user_tp_num_cs, user_password_cs)
elif user_login_page_option == 2:
user_staff_num_as = str(input("Staff number: "))
user_password_as = str(input("Password: "))
admin_staff_menu(user_staff_num_as, user_password_as)
elif user_login_page_option == 3:
user_staff_num_ds = str(input("Staff number: "))
user_password_ds = str(input("Password: "))
delivery_staff_menu(user_staff_num_ds, user_password_ds)
elif user_login_page_option == 4:
print("Proceeding back to Home Page...")
home_page()
elif user_login_page_option == 5:
print("Thank you for using APU Food Online Service")
print("Have a Nice Day....... BYE BYE")
exit()
else:
print("Error selection..........")
print("Please try again ^^")
user_login_page()
# Customer User Login Verification Page

def user_login_cs(user_tp_num_cs, user_password_cs):


access = False
datafile = open("user_data.txt", "r")
for data in datafile:
tp_cs, name_cs, phone_cs, password_cs = data.split(",")
tp_cs = tp_cs.strip()
password_cs = password_cs.strip()
if tp_cs == user_tp_num_cs and password_cs == user_password_cs:
name_cs = name_cs.strip()
access = True
print("Dear " + name_cs + ". Welcome to APU Food Online Service")
print("Dear customer, you have login successfully!")
break
else:
print("Error. Please try again.")
datafile.close()
if access:
customer_account_page()
else:
user_login_page()
# Customer User Interface

def customer_account_page():
print("""
** APU Food Online Service **
---------- Customer Log In Page ----------
1. Food Menu
2. Order Cart
3. Payment
4. Back to Login Page
5. Exit
""")
while True:
try:
customer_account_page_option = int(input("Please select an option: "))
break
except ValueError:
print("Something else went wrong, please choose the five option had
given above, thank you.")
if customer_account_page_option == 1:
print("Proceeding to Food Menu categories")
# food_menu()
elif customer_account_page_option == 2:
print("Proceeding to your order cart")
# order_cart()
elif customer_account_page_option == 3:
print("Proceeding to payment page")
# customer_payment()
elif customer_account_page_option == 4:
print("Proceeding back to Login Page")
user_login_page()
elif customer_account_page_option == 5:
print("Thank you for using APU Food Online Service")
print("Have a Nice Day....... BYE BYE")
exit()
else:
print("Error..........")
print("Please try again ^^")
customer_account_page()

home_page()

You might also like