-
Notifications
You must be signed in to change notification settings - Fork 635
Expand file tree
/
Copy pathP09_BankAccount.py
More file actions
30 lines (24 loc) · 847 Bytes
/
P09_BankAccount.py
File metadata and controls
30 lines (24 loc) · 847 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
# Author: OMKAR PATHAK
# This program illustrates all the OOP concepts learned uptil now
class BankAccount(object):
defaultAccNumber = 1 # Class Attribute
def __init__(self, name, balance = 0):
self.name = name
self.balance = balance
self.accountNumber = BankAccount.defaultAccNumber
BankAccount.defaultAccNumber = BankAccount.defaultAccNumber + 1
def deposit(self, amount):
self.balance += amount
def withdraw(self, amount):
if self.balance < amount:
print('Not enough balance!')
else:
self.balance -= amount
def getBalance(self):
return self.balance
if __name__ == '__main__':
myObj = BankAccount('Omkar', 1000)
myObj.deposit(1000)
print(myObj.getBalance())
myObj.withdraw(500)
print(myObj.getBalance())