-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.py
More file actions
27 lines (23 loc) · 844 Bytes
/
BankAccount.py
File metadata and controls
27 lines (23 loc) · 844 Bytes
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
class BankAccount:
def __init__(self, account_number, initial_balance):
self.__account_number = account_number
self.__balance = initial_balance
def get_account_number(self):
return self.__account_number
def get_balance(self):
return self.__balance
def deposit(self, amount):
if amount <= 0:
err = "cannot deposit zero or negative funds"
raise ValueError(err)
else:
self.__balance += amount
def withdraw(self, amount):
if self.__balance <= 0 or self.__balance < amount:
err = "insufficient funds"
raise ValueError(err)
elif amount <= 0:
err1 = "cannot withdraw zero or negative funds"
raise ValueError(err1)
else:
self.__balance -= amount