Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added __init__.py
Empty file.
Binary file added __pycache__/bank.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/client.cpython-39.pyc
Binary file not shown.
29 changes: 29 additions & 0 deletions bank.py
Original file line number Diff line number Diff line change
@@ -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!")
52 changes: 52 additions & 0 deletions client.py
Original file line number Diff line number Diff line change
@@ -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)


51 changes: 51 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -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