Skip to content
Shop

CommunityJoin Our PatreonDonate

Sponsored Ads

Sponsored Ads

Banking System

Build a banking system with the following features.

Functional Requirements

  • Can create a bank
  • Create an account
  • Deposit and withdraw 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 columndescription
idid of the item
namename of the item
namename of the item
namename of the item
namename of the item
Account columndescription
idid of the item
namename of the item
namename of the item
namename of the item
namename of the item
Client columndescription
idid of the item
namename of the item
namename of the item
namename of the item
namename of the item
Transaction columndescription
idid of the item
namename of the item
namename of the item
namename of the item
namename 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)