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 __pycache__/bank.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/client.cpython-39.pyc
Binary file not shown.
20 changes: 20 additions & 0 deletions bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'''**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, name):
self.clients.append(name)
def authentication(self, name, account_number):
if Client.account[str(account_number)]["name"] == name :
print("authentication is succesfull!")
return True
else :
print("Authentication failed! \nReason: Name not found.")
return False

33 changes: 33 additions & 0 deletions client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'''**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
class Client:
account={}
def __init__(self, name, total_amount):
self.name=name
self.total_amount=total_amount
self.account_number = random.randint(10000,99999)
print(f"Account created successfully! Your account number is: {self.account_number} ")
Client.account[str(self.account_number)] = {"name" : self.name , "total_amount" : self.total_amount}
'''def newaccount(self):
Client.account.update({str(self.account_number) : {"total_amount" : self.total_amount}})
print(f"Succesfull . Your new balance : {self.total_amount} ")'''
def withdraw(self, amount):
if self.total_amount > amount :
self.total_amount -= amount
print(f"\nThe sum of {amount} has been withdrawn from your account balance")
print(f"Your current account balance is: {self.total_amount}")
return self.total_amount
else:
return "Insufficient funds"
def deposit(self, amount):
self.total_amount+= amount
print(f"The sum of {amount} has been added to your account balance.")
print(f"Your current account balance is: {self.total_amount}")
return self.total_amount
def balance(self):
print ("Your current account balance is: {self.total_amount}")
131 changes: 131 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
'''**main.py**
- 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) [**hint:** use while loop]:
```
Welcome to International Bank!

Choose an option:

1. Open new bank account
2. Open existing bank account
3. Exit
```
Then it will take the user input:
- If it is 1, create an account
First ask the name and then the deposit amount to user:
```
To create an account, please fill in the information below.
Name:
Deposit amount:
```
After this, it creates the account and prints the menu again
```
Account created successfully! Your account number is: 88194

Choose an option:

1. Open new bank account
2. Open existing bank account
3. Exit
```
- If it is 2, asks following info
```
To access your account, please enter your credentials below.
Name:
Account Number:
```
First asks name and then account number.
If credentials are wrong, print following, and then print the menu again:
```
Authentication failed!
Reason: account not found.
```
If credentials are correct, prints the following menu:
```
Authentication successful!

Welcome irem!

Choose an option:

1. Withdraw
2. Deposit
3. Balance
4. Exit
```
And according to user input you can withdraw, deposit money. Or see the current balance.
If input is 1, asks for withdraw amount:
```
Withdraw amount:
```
And according to user input witdraws the amout and prints the menu again.
```
The sum of 100 has been withdrawn from your account balance.

Your current account balance is: 900
```
If input is 2, asks for deposit amount:
```
Deposit amount:
```
And according to user input, in this case 300. Prints following:
```

The sum of 300 has been added to your account balance.

Your current account balance is: 1200
```

If input is 3, shows the current balance:

```
Your current account balance is: 1200

```
If input is 4, it goes back to other menu.

- And lastly, in the main menu, if user input is 3: close the program'''

from client import Client
from bank import Bank

international_bank = Bank("International")
while True:
choice = input("Welcome to International Bank!\nChoose an option:\n1. Open new bank accountn\n2. Open existing bank accountn\n3. Exit")
if (choice == "1"):
print("To create an account, please fill in the information below.\nName\nDeposit amount:")
name =input("Name:")
total_amount=int(input("Deposit amount:"))
client = Client(name, total_amount)
international_bank.add_client(client)
elif (choice == "2"):
print("To access your account, please enter your credentials below.")
name =input("Name:")
account_number = int(input("Account Number:"))
'''if not international_bank.authentication(name, account_number=):
print("Authentication failed!\nReason: account not found.")'''
if international_bank.authentication(name, account_number) :
print("Authentication successful!\nWelcome {name}!")
choice1 = input("Choose an option:\n1. Withdraw\n2. Deposit\n3. Balance\n4. Exit")
if choice1 == "1":
withdraw = int(input("Withdraw amount:"))
for i in Bank.clients:
if i.name == name and i.account_number == account_number :
i.withdraw(withdraw)
elif choice1=="2":
Deposit_amount:int(input("Deposit amount:"))
for i in Bank.clients:
if i.name == name and i.account_number == account_number :
i.deposit(Deposit_amount)
print("The sum of {Deposit_amount} has been added to your account balance\nYour current account balance is: {Deposit_amount} + {balance}")
elif choice1=="3":
for i in Bank.clients:
if i.name == name and i.account_number == account_number :
print(i.balance())
elif choice1=="4":
break
else :
print("Error")
elif choice == "3" :
break
else:
print("error")