generated from CISC-CMPE-327/CI-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontEnd.py
51 lines (41 loc) · 2.58 KB
/
frontEnd.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
import sys
from atm import ATM
from agent import AGENT
def login(accountListFile, transactionSummary):
try:
choice = input("Welcome to the front end: \n")
if choice == 'login': # use correctly input login
print("Successfully login.")
status = False # check the validation of input
while status == False: # loop if user input invalid command
mode = input("Select mode to enter: \n") # select mode
if mode == "atm": # user correctly input atm
print("Successfully entered ATM mode.")
newAtm = ATM(accountListFile, transactionSummary) # create new atm object
status = True
elif mode == "agent": # user correctly input agent
print("Successfully entered agent mode.")
newAgent = AGENT(accountListFile, transactionSummary) # create new agent object
status = True
elif mode == "logout":
status = True
f = open(transactionSummary, "w")
f.writelines("EOS")
f.close()
else: # error for anything else
print("Error:Invalid mode choice, please input a valid mode choice!")
print("Successfully logout.")
login(accountListFile, transactionSummary)
else: # invalid input
print("Error:Please login first!")
login(accountListFile, transactionSummary)
except:
quit # exit program
def main():
accountListFile = sys.argv[1]
transactionSummary = sys.argv[2]
# accountListFile = "D:/CISC327/project/A3_package/testCase/deposit/input/t1.0in.txt"
# transactionSummary = "D:/CISC327/project/A3_package/testCase/deposit/output"
login(accountListFile, transactionSummary)
if __name__ == "__main__":
main()