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 0000000..479ad9a Binary files /dev/null and b/__pycache__/bank.cpython-39.pyc differ diff --git a/__pycache__/client.cpython-39.pyc b/__pycache__/client.cpython-39.pyc new file mode 100644 index 0000000..0fd2201 Binary files /dev/null and b/__pycache__/client.cpython-39.pyc differ 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