-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbankacc.py
More file actions
34 lines (23 loc) · 827 Bytes
/
bankacc.py
File metadata and controls
34 lines (23 loc) · 827 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
28
29
30
31
32
class InsufficientFundsEror(Exception):
pass
class BankAccount:
acc_counter = 100
def __init__(self, name, balance=0):
BankAccount.acc_counter += 1
self.__acc = BankAccount.acc_counter
self.name = name
self.__balance = balance
def deposit(self, amount):
self.__balance += amount
def withdraw(self, amount):
if 0 < amount <= self.__balance:
self.__balance -= amount
else:
raise InsufficientFundsEror("Not Enough Funds you rokiee")
def get_balance(self):
return self.__balance
def details(self):
return self.__acc, self.name, self.__balance
Harshith = BankAccount('Harshith', 100000)
Reddy = BankAccount('Reddy', 1000055555)
print(Harshith.details(), '\n', Reddy.details())