-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession9-FinalProject.py
More file actions
304 lines (245 loc) · 9.39 KB
/
session9-FinalProject.py
File metadata and controls
304 lines (245 loc) · 9.39 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
class Customer:
def __init__(self, name, password, fatherName, cash, ID):
self.name = name
self.password = password
self.fatherName = fatherName
self.cash = cash
self.ID = ID
self.loan = 0
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_password(self):
return self.password
def set_password(self, password):
self.password = password
def get_fatherName(self):
return self.fatherName
def set_fatherName(self, fatherName):
self.fatherName = fatherName
def get_cash(self):
return self.cash
def set_cash(self, cash):
self.cash = cash
def get_ID(self):
return self.ID
def set_ID(self, ID):
self.ID = ID
def get_loan(self):
return self.loan
def set_loan(self, loan):
self.loan = loan
def information(self):
return f"Name: {self.name.title()}\tFather name: {self.fatherName.title()}\nCash amount: {self.cash}\tID: {self.ID}"
class Employee:
def __init__(self, name, password, fatherName, ID):
self.name = name
self.password = password
self.fatherName = fatherName
self.ID = ID
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_password(self):
return self.password
def set_password(self, password):
self.password = password
def get_fatherName(self):
return self.fatherName
def set_fatherName(self, fatherName):
self.fatherName = fatherName
def get_ID(self):
return self.ID
def set_ID(self, ID):
self.ID = ID
def information(self):
return f"Name: {self.name.title()}\tFather name: {self.fatherName.title()}\nId: {self.ID}"
def isDuplicateID(id):
for customer in AllCustomers:
if customer.get_ID() == id:
return True
return False
def isDuplicateEmployeeID(id):
for employee in AllEmployees:
if employee.get_ID() == id:
return True
return False
def newCustomer():
name = input("\nPlease enter the customer's name: ")
fatherName = input("Please enter the customer's father's name: ")
cash = int(input("Please enter the customer's cash amount: "))
ID = int(input("Please provide the customer's ID number: "))
while isDuplicateID(ID):
print("ID already exists. Please provide a unique customer's ID number.")
ID = int(input("Please provide the customer's ID number: "))
password = input("Enter a password: ")
customer = Customer(name, password, fatherName, cash, ID)
AllCustomers.append(customer)
print("\nInformation saved successfully!")
def showCustomer():
for customer in AllCustomers:
print(f"\nName: {customer.get_name()}")
print(f"Father's Name: {customer.get_fatherName()}")
print(f"ID: {customer.get_ID()}")
print(f"Cash: {customer.get_cash() + customer.get_loan()}")
def findCustomer():
findID = int(input("\nPlease enter the customer's ID: "))
foundCustomer = None
for customer in AllCustomers:
if customer.get_ID() == findID:
foundCustomer = customer
break
if foundCustomer:
print(f"\nName: {foundCustomer.get_name()}")
print(f"Father's Name: {foundCustomer.get_fatherName()}")
print(f"ID: {foundCustomer.get_ID()}")
print(f"Cash: {foundCustomer.get_cash() + foundCustomer.get_loan()}")
else:
print("\nThis customer doesn't exist")
def renameCustomer():
findID = int(input("\nPlease enter the customer's ID: "))
foundCustomer = None
for customer in AllCustomers:
if customer.get_ID() == findID:
foundCustomer = customer
break
if foundCustomer:
new_name = input("\nPlease enter the customer's new name: ")
foundCustomer.set_name(new_name)
print("\nInformation saved successfully!")
else:
print("\nThis customer doesn't exist")
def deleteCustomer():
findID = int(input("\nPlease enter the customer's ID: "))
foundCustomer = None
for customer in AllCustomers:
if customer.get_ID() == findID:
foundCustomer = customer
break
if foundCustomer:
AllCustomers.remove(foundCustomer)
print("\nInformation saved successfully!")
else:
print("\nThis customer doesn't exist")
def loanCustomer():
findID = int(input("\nPlease enter customer's ID: "))
foundCustomers = [customer for customer in AllCustomers if customer.get_ID() == findID]
if foundCustomers:
for customer in foundCustomers:
username = input("Please enter username: ")
password = input("Please enter password: ")
if customer.get_name() == username and customer.get_password() == password:
loan = int(input("\nPlease enter the amount: "))
if loan >= customer.get_cash():
customer.set_loan(loan)
print("\nInformation saved successfully!")
else:
customer.set_cash(loan + customer.get_cash())
print("\nInformation saved successfully!")
else:
print("Wrong input!")
break
else:
print("\nThis customer doesn't exist")
def newEmployee():
name = input("\nPlease enter employee's name: ")
fatherName = input("Please enter employee's father name: ")
idNumber = int(input("Please provide employee's ID number: "))
while isDuplicateEmployeeID(idNumber):
print("ID already exists. Please provide a unique employee's ID number.")
idNumber = int(input("Please provide employee's ID number: "))
password = input("Enter a password: ")
employee = Employee(name, password, fatherName, idNumber)
AllEmployees.append(employee)
print("\nInformation saved successfully!")
def showEmployee():
for employee in AllEmployees:
print(f"\nName: {employee.get_name()}")
print(f"Father's Name: {employee.get_fatherName()}")
print(f"ID: {employee.get_ID()}")
def findEmployee():
findID = int(input("\nPlease enter employee's ID: "))
for employee in AllEmployees:
if employee.get_ID() == findID and employee.get_password() == input("Please enter password: "):
print(f"\nName: {employee.get_name()}")
print(f"Father's Name: {employee.get_fatherName()}")
print(f"ID: {employee.get_ID()}")
return
print("Wrong input or employee not found")
def renameEmployee():
findId = int(input("\nPlease enter employee's ID: "))
for employee in AllEmployees:
if employee.get_ID() == findId and employee.get_password() == input("Please enter password: "):
new_name = input("\nPlease enter employee's new name: ")
employee.set_name(new_name)
print("\nInformation saved successfully!")
return
print("Wrong input or employee not found")
def deleteEmployee():
findID = int(input("\nPlease enter employee's ID: "))
for employee in AllEmployees:
if employee.get_ID() == findID and employee.get_password() == input("Please enter password: "):
AllEmployees.remove(employee)
print("\nInformation saved successfully!")
return
print("Wrong input or employee not found")
AllCustomers = []
AllEmployees = []
while True:
option = int(input("\nWelcome to our bank, how can we help you today? \n1-Add a customer\n2-Show all customers\n3-Find a customer\n4-Edit a customer\n5-Delete a customer\n6-Loan application\n7-Add an employee\n8-Show all employees\n9-Find an employee\n10-Edit an employee\n11-Delete an employee\n12-Exit\nEnter: "))
if option == 1:
newCustomer()
elif option == 2:
if AllCustomers:
showCustomer()
else:
print("There are no customers")
elif option == 3:
if AllCustomers:
findCustomer()
else:
print("There are no customers")
elif option == 4:
if AllCustomers:
renameCustomer()
else:
print("There are no customers")
elif option == 5:
if AllCustomers:
deleteCustomer()
else:
print("There are no customers")
elif option == 6:
if AllCustomers:
loanCustomer()
else:
print("There are no customers")
elif option == 7:
newEmployee()
elif option == 8:
if AllEmployees:
showEmployee()
else:
print("There are no employees")
elif option == 9:
if AllEmployees:
findEmployee()
else:
print("There are no employees")
elif option == 10:
if AllEmployees:
renameEmployee()
else:
print("There are no employees")
elif option == 11:
if AllEmployees:
deleteEmployee()
else:
print("There are no employees")
elif option == 12:
print("Have a nice day!")
break
else:
print("Wrong input!")