-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
79 lines (65 loc) · 2.89 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
# Insert Card => PIN number => Select Account => See Balance/Deposit/Withdraw
from atm import ATM
from constant import Account, Transaction
if __name__ == "__main__":
atm = ATM()
while(True):
print('\n################### \n')
print('ATM is running... \n')
print('################### \n')
while True:
print('Please insert your 16-digit card number to start')
cardNumber = input('****-****-****-****: ')
if not atm.insertCard(cardNumber):
print('Error: ', cardNumber, ' is not valid card number.\n')
continue
else:
print('Processing...\n')
break
while True:
print('Please insert your 4-digit pin number')
pinNumber = input('****: ')
if not atm.insertPin(pinNumber):
print('Error: Invalid pin number.\n')
else:
print('Processing...\n')
break
print('Fetching Accounts...')
accountsToShow = atm.showAccounts()
if not accountsToShow:
print('Error: No accounts found associated with this card number.\n')
continue
for account in accountsToShow:
print('Account: {} '.format(account))
print('\n')
print('Please select account for transaction')
while True:
account = input('{} or {}?: '.format(
Account['CHECKING'], Account['SAVINGS']))
if account not in Account.values():
print("Error: Please input valid account type.\n")
if atm.selectAccount(account):
print('Success: You have selected {} account type.\n'.format(
account))
break
else:
print("Error: '{}' is not valid account type.\n".format(account))
print('Please choose desired transaction to be performed with this {} account'.format(
account))
while True:
transaction = input("{} or {} or {}?: ".format(
Transaction['BALANCE'], Transaction['DEPOSIT'], Transaction['WITHDRAW']))
result = atm.executeTransaction(transaction, 0)
if transaction == Transaction['DEPOSIT'] or transaction == Transaction['WITHDRAW']:
inputAmount = int(
input('Please input the amount to {}: '.format(transaction.lower())))
result = atm.executeTransaction(transaction, inputAmount)
elif transaction == Transaction['BALANCE']:
result = atm.executeTransaction(transaction, 0)
else:
print('Error: Please select valid transaction type')
continue
print('\n')
print('{}: {}'.format(result['status'], result['message']))
print('Account Balance: {}\n'.format(result['balance']))
break