-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatm2Improved.py
More file actions
129 lines (95 loc) · 3.87 KB
/
Copy pathatm2Improved.py
File metadata and controls
129 lines (95 loc) · 3.87 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
import random # geneate account number for new user
import time # show time to user upon login
localtime = time.asctime(time.localtime(time.time()))
print("Current local time is :", localtime)
# register
# - first name, last name , email
# - generate user account
# login
# - account number and and password
# Generated acct numbers for test users to add for the dictionary
# Use same format from register function
#database = {4103041978: ["Queen", "B", "QB@aol.com", "Mom"]}
#database = {4563766566: ["Oakleigh", "B", "OB@aol.com", "Baby"]}
database = {7147200027: ["Papa", "P", "PP@aol.com", "Dad"]}
def init():
isValidOptionSelected = False
print("Welcome of Bank of QueenB!")
while isValidOptionSelected == False:
haveAccount = int(input("Do you have an account with us: 1 (yes) or 2 (no)? \n"))
if (haveAccount == 1):
isValidOptionSelected = True
login()
elif (haveAccount == 2):
isValidOptionSelected = True
register()
else:
print("You have entered an invalid selection")
def login():
print("Please login to your account.")
isLoginSuccessful = True
while isLoginSuccessful == True:
accountNumberFromUser = int(input("What is your account number? \n"))
password = input("What is your password? \n")
for accountNumber, userDetails in database.items():
if (accountNumber == accountNumberFromUser):
if (userDetails[3] == password):
isLoginSuccessful = False
print("Invalid account or password, please try again!")
bankOperation(userDetails)
def register():
print("******** Register now! ********* ")
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 your password? \n")
accountNumber = generateAccountNumber()
database[accountNumber] = [first_name, last_name, email, password]
# return database; #for testing purposes, dont neeed to display output of user
print("Your account has been created!! ")
# below prints pulled in from p23
print("== ==== ===== ==== ===")
print("Your account number is: %d" % accountNumber)
print("Make sure you keep it safe!")
print("== ==== ===== ==== ===")
login()
###print("This is the register function")
def bankOperation(user):
print("Welcome %s %s" % (user[0], user[1]))
selectdOption = int(
input("What would you like to do? (1) deposit (2) withdrawl (3) Logout (4) Report Issue (5) Exit).\n"))
if (selectdOption == 1):
depositOperation()
elif (selectdOption == 2):
withdrawawlOperation()
elif (selectdOption == 3):
login()
elif (selectdOption == 4): #Added new selection for user from previous assignment
reportComplaint()
elif (selectdOption == 5):
exit() # to leave the program
else:
print("Invalid Option selected, please try again!")
bankOperation(user)
##set up new functions from each operation: withdrawl, deposit and complaint
def withdrawawlOperation():
withdrawal = input("How much would you like to withdraw? \n")
print("Please take your $" + withdrawal + "!\n")
pass
#Improvement
def depositOperation():
deposit = (input("How much would you like to deposit? \n"))
print("You have deposited $" + deposit + "! \n")
pass
def generateAccountNumber():
# print("Generating Account Number") ## dont need to show this to user
return random.randrange(1111111111, 9999999999)
#Improvement
def reportComplaint():
# print("You selected option %s" % selectedOption)
complaint = input("What issue will you like to report? \n")
print("Thank you for contacting us! \n")
pass
###Actual Banking System ###
### print(generateAccountNumber())
init()