forked from ashishps1/awesome-low-level-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.py
30 lines (23 loc) · 789 Bytes
/
account.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from portfolio import Portfolio
from exceptions import InsufficientFundsException
class Account:
def __init__(self, account_id, user, initial_balance):
self.account_id = account_id
self.user = user
self.balance = initial_balance
self.portfolio = Portfolio(self)
def deposit(self, amount):
self.balance += amount
def withdraw(self, amount):
if self.balance >= amount:
self.balance -= amount
else:
raise InsufficientFundsException("Insufficient funds in the account.")
def get_account_id(self):
return self.account_id
def get_user(self):
return self.user
def get_balance(self):
return self.balance
def get_portfolio(self):
return self.portfolio