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
Binary file added Bank_Project/__pycache__/bank.cpython-39.pyc
Binary file not shown.
Binary file added Bank_Project/__pycache__/client.cpython-39.pyc
Binary file not shown.
29 changes: 29 additions & 0 deletions Bank_Project/bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#* - 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



class Bank:
clients = [[11111,'aaa',1000], [22222,'bbb',2000], [33333,'ccc',3000]]
def __init__(self,name):
self.name = name

def add_client(self,account_number,name,total_amount):
self.name = name
self.total_amount = total_amount
self.account_number = account_number
Bank.clients.append([self.account_number,self.name,self.total_amount])


def authentication(self,name,account_number):
self.name = name
self.account_number = account_number
# for i in range(len(self.clients)):
# if (self.account_number == self.clients[i][0] and self.name == self.clients[i][1]):
# return True
for i in self.clients:
if i[0] == self.account_number and i[1] == self.name:
return True
51 changes: 51 additions & 0 deletions Bank_Project/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# - 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
import string
from bank import Bank


class Client:

def __init__(self,name,total_amount):
self.name = name
self.total_amount = total_amount
self.account_number = random.randint(10000,99999)

b1 = Bank(self.name)
b1.add_client(self.account_number,self.name,self.total_amount)
print(f'Account created successfully! Your account number is: {self.account_number}')



def withdraw(self,account_number,amount):
self.account_number = account_number
self.amount = amount
for i in range(len(Bank.clients)):
if self.account_number==Bank.clients[i][0]:
Bank.clients[i][2] -= self.amount
self.total_amount = Bank.clients[i][2]
print(f'The sum of {self.amount} has been withdrawn from your account balance.')
print(f'Your current account balance is: {self.total_amount}')

def deposit(self,account_number,amount):
self.account_number = account_number
self.amount = amount
for i in range(len(Bank.clients)):
if self.account_number==Bank.clients[i][0]:
Bank.clients[i][2] += self.amount
self.total_amount = Bank.clients[i][2]
print(f'The sum of {self.amount} has been added to your account balance.')
print(f'Your current account balance is: {self.total_amount}')

def balance(self,account_number):
self.account_number = account_number
for i in range(len(Bank.clients)):
if self.account_number==Bank.clients[i][0]:
self.total_amount = Bank.clients[i][2]
print(f'Your current account balance is: {Bank.clients[i][2]}')

78 changes: 78 additions & 0 deletions Bank_Project/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This class initially will create a bank object with a name you choose and
# then will print the following menu (it should print this menu, until user says exit)


from bank import Bank
from client import Client
import time

while True:
print('''
Welcome to International Bank!

Choose an option:

1. Open new bank account
2. Open existing bank account
3. Exit
''')
kies_1 = int(input('your choise : '))
if kies_1 == 1:
print('''
To create an account, please fill in the information below.
''')
a = str(input('Name: '))
b = int(input('Deposit amount: '))
Client(a,b)


elif kies_1 == 2:
print('''
To access your account, please enter your credentials below.
''')
while True:
name = input('Name: ')
account_number =int(input('Account Number: '))
authen = Bank.authentication(Bank,name,account_number)
if authen == True:
print('Authentication successful!')
break
else:
print('Authentication failed!\nReason: account not found.')


continue

while True:
print(f'''
Welcome {name}!

Choose an option:

1. Withdraw
2. Deposit
3. Balance
4. Exit
''')
kies_2 = int(input('your choise : '))
if kies_2 == 1:
amount = int(input('Withdraw amount: '))
Client.withdraw(Client,account_number,amount)
time.sleep(2)

elif kies_2 ==2:
deposit = int(input('Deposit amount: '))
Client.deposit(Client,account_number,deposit)
time.sleep(2)

elif kies_2 == 3:
Client.balance(Client,account_number)
time.sleep(2)

elif kies_2 == 4:
break



elif kies_1 == 3:
break