-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomer.py
More file actions
51 lines (40 loc) · 1.64 KB
/
Copy pathcustomer.py
File metadata and controls
51 lines (40 loc) · 1.64 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
import random
import account
import functions
class Customer:
def __init__(self,name: str,email: str,type : str,balance: float,pswd):
assert len(type) == 2 and (type.upper() == 'SA' or type.upper() == 'CA'), "Wrong/Invalid Type of Account! Try Again..."
self.name = name.replace(" ","_").lstrip('_').rstrip('_')
self.email = email.replace(" ","_").lstrip('_').rstrip('_')
self.password = pswd
customer_details = Customer.create_customer(self) + f' {self.password}'
with open("data/customer.txt",'r') as file:
data = file.readlines()
file.close()
data.append(customer_details+'\n')
with open("data/customer.txt",'w') as file:
for i in data:
file.writelines(i)
file.close()
account.Account(f"{customer_details.split(" ")[2]}",type,balance)
print(f"Successfully Created Customer with ID: {customer_details.split(" ")[2]} ")
def create_customer(self):
name = self.name
email = self.email
with open("data/customer.txt",'r') as file:
data = file.readlines()
custIDsNo = list()
for i in data:
custid = i.split(" ")[2]
custIDsNo.append(custid[4:])
try:
while True:
num = f"{random.randrange(1000,9999)}"
if num not in custIDsNo:
break
self.cust_id = f"BANK0{num}"
except:
raise Exception("Account Limit Reached. Contact IT Manager...")
return f'{name} {email} {self.cust_id}'
def get_customer(self):
...