Banking System
Build a banking system with the following features.
Functional Requirements
- Can create a
bank
- Create an
account
Deposit
andwithdraw
from an account
Sample below:
python
class Bank(x):
print("do bank stuff")
class Account(x):
print("do account stuff")
class Client(x):
print("do client stuff")
class Transaction(x):
print("do transaction stuff")
Non Functional Requirements
- Item
- Item
Schema
Bank column | description |
---|---|
id | id of the item |
name | name of the item |
name | name of the item |
name | name of the item |
name | name of the item |
Account column | description |
---|---|
id | id of the item |
name | name of the item |
name | name of the item |
name | name of the item |
name | name of the item |
Client column | description |
---|---|
id | id of the item |
name | name of the item |
name | name of the item |
name | name of the item |
name | name of the item |
Transaction column | description |
---|---|
id | id of the item |
name | name of the item |
name | name of the item |
name | name of the item |
name | name of the item |
Business Rules
Rules about how things should work...
Solution
py
class Bank:
def __init__(self,name="New Bank"):
self.name = name
self.accounts = []
def add_account(self,x):
self.accounts.append(x)
class Account:
def __init__(self,name="New Account",account_holder=None):
self.amount = 0
self.name = name
self.account_holder = account_holder
def withdraw(self,x):
self.amount -= x
def deposit(self,x):
self.amount += x
def __repr__(self):
return str({
"name": self.name,
"amount": self.amount,
"account_holder": self.account_holder
})
chase = Bank("Chase")
print(chase.name)
my_account = Account("Household","Tutorial Doctor")
my_account.deposit(600.00)
my_account.withdraw(100.00)
print(my_account.amount)
chase.add_account(my_account)
print(my_account)
print(chase.accounts)