-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank_Account_Example.py
More file actions
38 lines (28 loc) · 829 Bytes
/
Bank_Account_Example.py
File metadata and controls
38 lines (28 loc) · 829 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
33
34
35
36
37
38
class CheckingAccount:
def __init__(self,name,balance):
self.name=name
self.balance=balance
def add_amount(self,amount):
self.balance+=amount
def __str__(self):
return "{} and {}".format(self.name,self.balance)
sa=CheckingAccount("shashank",100)
sa.add_amount(200)
print(sa)
class Saving_Account:
withdraw_count=0
def __init__(self,name,balance):
self.name=name
self.balance=balance
def withdraw_amount(self,amount):
if self.withdraw_count <1:
self.balance-=amount
self.withdraw_count+=1
else:
print('Cannot withdraw the amount')
def __str__(self):
return "{} {}".format(self.name,self.balance)
sa=Saving_Account("Shashank",300)
sa.withdraw_amount(100)
sa.withdraw_amount(20)
print(sa)