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
21 changes: 21 additions & 0 deletions bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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]

print('''
Authentication failed!
Reason: account not found.
''')

Binary file added bank1.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from random import randint

class Client:

available_nums = []

def __init__(self, name, total_amount):
self.name = name
self.total_amount = total_amount
self.account_number = self.generate_random()
self.available_nums.append(self.account_number)

def generate_random(self):
num = randint(10000, 99999)
while num in self.available_nums:
num = randint(10000, 99999)
return num

def withdraw(self, amount):
if self.total_amount >= amount:
self.total_amount -= amount
print(f"The sum of {amount} has been withdrawn from your account balance.")
self.balance()
else:
print("Not enough money!")

def deposit(self, amount):
self.total_amount += amount
print(f"The sum of {amount} has been added to your account balance.")
self.balance()

def balance(self):
print(f"Your current account balance is: {self.total_amount}")
return self.total_amount

62 changes: 62 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from bank import Bank
from client import Client

bank = Bank("ING")

print(f"Welcome to {bank.name}!")

available = True

while available:
print('''
Choose an option:

1. Open new bank account
2. Open existing bank account
3. Exit

''')
user_input = int(input())
if user_input == 1:
print("To create an account, please fill in the information below.")
name = input("Name:")
amount = int(input("Deposit amount:"))
client = Client(name, amount)
bank.add_client(client)
print(f"Account created successfully! Your account number is: {client.account_number}")
elif user_input == 2:
print("To access your account, please enter your credentials below.")
name = input("Name:")
account_no = int(input("Account Number:"))
curr_client = bank.authentication(name, account_no)
if curr_client:
authorized = True
while authorized:
print(f'''
Welcome {curr_client.name}!

Choose an option:

1. Withdraw
2. Deposit
3. Balance
4. Exit
''')
curr_input = int(input("1, 2, 3, or 4:"))
if curr_input == 1:
w_amount = int(input("Withdraw amount:"))
curr_client.withdraw(w_amount)
elif curr_input == 2:
d_amount = int(input("Deposit amount:"))
curr_client.deposit(d_amount)
elif curr_input == 3:
curr_client.balance()
elif curr_input == 4:
authorized = False
else:
print("Invalid input, please enter 1, 2, 3, or 4!")
elif user_input == 3:
available = False
else:
print('Input should be 1, 2, or 3!')