forked from xyluz/pythonclass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmock_atm_improved.py
More file actions
131 lines (107 loc) · 4.26 KB
/
mock_atm_improved.py
File metadata and controls
131 lines (107 loc) · 4.26 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import datetime
import random
beginning_balance = 200
database = {}
def generated_account_number():
return random.randrange(1111111111,9999999999)
account_number = generated_account_number()
def login():
print("********** Login **********")
account_number_from_user = int(input("What is your account number? \n"))
password = input("What is your password \n")
for account_number,user_details in database.items():
if(account_number == account_number_from_user):
if(user_details[3] == password):
bank_operation(user_details)
break
else:
print('Invalid username or password')
init()
def register():
print("********** Register **********")
email = input("What is your email address? \n")
first_name = input("What is your first name? \n")
last_name = input("What is your last name? \n")
password = input("Create a password for yourself \n")
account_number = generated_account_number()
database[account_number] = [first_name, last_name, email, password]
print("Your account has been created")
print(" === ==== ====== ==== ===")
print(f'Your account number is {account_number}')
print("Make sure you keep it safe")
print(" === ==== ====== ==== ===")
login()
def init():
print("\nWelcome to PythonBank")
have_account = int(input("Do you have account with us: (1) Yes (2)No \n"))
if(have_account == 1):
login()
elif(have_account == 2):
register()
else:
print("You have selected invalid option")
init()
def bank_operation(user):
print(f'\nHello {user[0]} {user[1]}')
print("How can I help you today? \nAvailable Services:")
selected_option = int(input('(1) Withdrawl \n(2) Deposit \n(3) Complaint \n(4) Logout \n(5) Exit \nPlease select an option: '))
if selected_option == 1:
withdrawal_operation(user)
elif selected_option == 2:
deposit_operation(user)
elif selected_option == 3:
complaint_operation(user)
elif selected_option == 4:
logout()
elif selected_option == 5:
exit()
else:
print("Invalid option selected")
bank_operation(user)
return user
def withdrawal_operation(user):
print("\nWithdrawal Menu")
print(f'You would like to make a withdrawl \nIs that correct?')
confirm_withdrawl = int(input('Press (1) for Yes (2) for No \n'))
if confirm_withdrawl == 1:
withdrawl_amount = int(input('How much would you like to withdraw?: \n'))
print(f'You have chosen to withdrawl ${withdrawl_amount} \nPlease take your cash \nHave a nice day!')
init()
elif confirm_withdrawl == 2:
bank_operation(user)
else:
print('Invalid option selected, please try again')
withdrawal_operation(user)
def deposit_operation(user):
print("Deposit Menu")
print('You would like to make a deposit \nIs that correct?')
confirm_deposit = int(input('Press (1) for Yes (2) for No \n'))
if confirm_deposit == 1:
deposit_amount = int(input('How much would you like to withdraw?:\n '))
print(f'You have chosen to deposit ${deposit_amount}')
current_balance = deposit_amount + beginning_balance
print(f'Your current balance is ${current_balance} \nHave a nice day!')
init()
elif confirm_deposit == 2:
bank_operation(user)
else:
print('Invalid option selected, please try again')
deposit_operation(user)
def complaint_operation(user):
print("Complaint Menu")
print('You would like to make a complaint \nIs that correct?')
confirm_complaint = int(input('Press (1) for Yes (2) for No \n'))
if confirm_complaint == 1:
customer_complaint = str(input('What issue would you like to report?: '))
print(f'Thank you for contacting us \nWe appriciate your feedback \nHave a nice day!')
init()
elif confirm_complaint == 2:
bank_operation(user)
else:
print('Invalid option selected, please try again')
complaint_operation(user)
def logout():
login()
def exit():
init()
init()