From 2a6849e1d8a25c8749b15f54bd08bdcfc513c683 Mon Sep 17 00:00:00 2001 From: Mustafa Kemal Date: Fri, 22 Oct 2021 23:38:29 +0200 Subject: [PATCH] Week06_Hw --- __init__.py | 0 __pycache__/bank.cpython-39.pyc | Bin 0 -> 1371 bytes __pycache__/client.cpython-39.pyc | Bin 0 -> 2057 bytes bank.py | 29 +++++++++++++++++ client.py | 52 ++++++++++++++++++++++++++++++ main.py | 51 +++++++++++++++++++++++++++++ 6 files changed, 132 insertions(+) create mode 100644 __init__.py create mode 100644 __pycache__/bank.cpython-39.pyc create mode 100644 __pycache__/client.cpython-39.pyc create mode 100644 bank.py create mode 100644 client.py create mode 100644 main.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/__pycache__/bank.cpython-39.pyc b/__pycache__/bank.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..479ad9a8b9cad0635691041cf8a0beb4e89ab493 GIT binary patch literal 1371 zcmZWpO>Yx15VdzVAFSH&Q6y9j$RG}+QqvQhP}NcdLV^mZAVehOb=GdP&BjS>Z>v^8 z9NHfO2M+y9d*#HP6DMZ8O_LT&cI+8@=FPmf5sQm4f$`^w6+c5le&Jz$fQ@Xxw2xqs zq)Q}~K~9H3H=yJ-k)e#vh>T8yZYXOzq+J)^C?P8=J)sAk@$t$^9Ivv^qkOlfBmmS@&= z;x{^TnaJ~F<}flEtH?dY)Nt&MI{?Tht#Hh64VCMUBuj*pyb7AI3)@jYOZ!ZW$4W~J zfw2h8%G}6jfRLL24GMG9#Mh%IqJVeWWvOu4NMDAItJqEq6f|X4W+KvbRA|R_G3+S= zwOck82HN11vAz>?5#j9&Rs0*cB5hjMw>-)ekMkpd!v;+I1QtcQ6o?J>2v7**o{?@; z(b}!anykaQE*n5?vy70l6kksV?s0Cxw5X&Boe&N}*&*k28z4kjQ9CFjtMXk_gB$0> zG~nm&`r1bem8=a5AbS_eABwyuY_E`Fu(pL7dAj=k7%0)J??$r7)#@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tw*gkocH^ zS_RGk&ni}xEV9~_JyvA^n$o0YV6NCPBgn^~qD#sz-=A%@n*pW{CT$cIwI~{uB@6!R zQS>zDNwrg@&>;ok0O!vqDY}h yg@but*jfVZpyVD(h0G~+L%*t-pH!YMQC>V%1P?2N_Yk}CJ;x8M+g9TPhyDXjd-y>B literal 0 HcmV?d00001 diff --git a/bank.py b/bank.py new file mode 100644 index 0000000..532d427 --- /dev/null +++ b/bank.py @@ -0,0 +1,29 @@ +'''**bank.py** + +- You will have class `Bank`. This bank will have instance variable `name` and class variable `clients` list. +Initially this list will be empty. +- This class will have method `add_client` method which appends the client to list +- And lastly this class will have `authentication` method +which takes `name` and `account_number` as parameters and authenticates the client +''' + + +from client import Client + + +class Bank: + clients=[] + + def __init__(self,name): + self.name=name + + def add_client(self,client): + self.clients.append(client) + + def authentication(self,name,account_number): + for i in range(len(self.clients)): + if name==self.clients[i]['name'] and account_number==self.clients[i]['account_number']: + print("Authentication successful!") + return self.clients[i] + else: + print("Authentication not successful!") \ No newline at end of file diff --git a/client.py b/client.py new file mode 100644 index 0000000..326d99f --- /dev/null +++ b/client.py @@ -0,0 +1,52 @@ +'''**client.py** +- You will have class `Client` inside this file. +- Class `Client` will have `account_number`, `name`, `total_amount` attributes +- `__init__` method will initialize these variables, +it will take `name` and `total_amount` as params and will assign a random 5 digit int to `account_number` +- Lastly this class will have `withdraw`, `deposit` and `balance` methods.''' + +import random + +rnd_list=list(set(random.randint(10000,99999) for i in range(9999))) + +class Client: + i=0 + def __init__(self, name, total_amount): + + self.name=name + self.total_amount=total_amount + self.account_number=rnd_list[Client.i] + self.account={'name':self.name,'total_amount':self.total_amount,"account_number":self.account_number} + Client.i+=1 + + def withdraw(self,amount): + amount=float(input("Enter withdraw amount :")) + if self.total_amount >= amount: + self.account -=amount + print(f"The sum of {amount} has been withdrawn from your account balance.") + print(f"Current account balance is : {self.total_amount}") + + else: + print("Current account balance is not enough.") + return self.account + + + def deposit(self,amount): + + amount=float(input("Enter deposit amount :")) + self.total_amount+=amount + print(f"The sum of {amount} has been added to your account balance.") + print(f"Current account balance is : {self.total_amount}") + return self.total_amount + + + def balance(self): + print(f"Current account balance is : {self.total_amount}") + + + + +client1=Client +print(client1) + + diff --git a/main.py b/main.py new file mode 100644 index 0000000..97eb7a5 --- /dev/null +++ b/main.py @@ -0,0 +1,51 @@ + +from client import Client +from bank import Bank + + +class main(Bank): + bank_name=Bank(input("Name of Bank : ")) + print(f"Welcome to {bank_name}") + + while True: + + print("""Choose an option: + 1. Open new bank account + 2. Open existing bank account + 3. Exit + """) + demands=int(input("Please Enter you want to transaction : ")) + + if demands==1: + name=input("Name :") + new_amount=int(input("Your amount :")) + customer1=Client(name,new_amount) + bank_name.add_client(customer1.account) + print(f"Account created successfully.Your account number is {customer1.account['account_number']}") + + elif demands==2: + name=input("Name :") + account_number=int(input("Enter your account number :")) + ##clint_credentials=bank_name.authentication(name,account_number) + + while True: + print("""Choose an transaction + 1. Withdraw, + 2. Deposit + 3. Balance + 4. Exit""") + + transaction=int(input("Please choice transsaction :")) + + if transaction==1: + Client.deposit() + + elif transaction == 2: + Client.withdraw(1) + elif transaction == 3: + Client.balance() + else: + break + else : + print("Have a Nice Day!") + break \ No newline at end of file