/
controller.py
56 lines (47 loc) · 1.64 KB
/
controller.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
#!usr/bin/env python3
#July 2 -- build out view and controller and use model
import view as v
from model import Account
def start():
while True:
selection = v.get_initial_menu_choice()
print(f'this was the selection: {selection}')
#is it better to test for quit first or go in same order as menu?
if int(selection)==1: #create account
first_name, last_name, pin = v.create_account_prompt()
account=Account()
account_num = account.create_account(first_name, last_name, pin)
account.save_account()
account.save_file()
v.confirm_account_creation(account.account_num)
elif int(selection)==2: #login
account = Account()
account_num, pin = v.login_prompt()
authenticated_user = account.login(account_num, pin)
#if the login is successful -- validated by model show next menu
while authenticated_user:
selection = v.get_main_menu_choice(
authenticated_user.first_name,
authenticated_user.last_name,
authenticated_user.account_num
)
if int(selection)==1: #check balance
v.show_balance(authenticated_user.get_balance())
elif int(selection)==2: #withdraw
amount = v.withdrawal_prompt()
authenticated_user.withdraw(amount)
authenticated_user.save_account()
authenticated_user.save_file()
elif int(selection)==3: #deposit
amount = v.deposit_prompt()
authenticated_user.deposit(amount)
authenticated_user.save_account()
authenticated_user.save_file()
elif int(selection)==4: #quit
v.confirm_quit()
break
elif int(selection)==3:
v.confirm_quit()
break
if __name__=='__main__':
start()