-
Notifications
You must be signed in to change notification settings - Fork 0
/
ATM.py
37 lines (29 loc) · 1.03 KB
/
ATM.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
31
32
33
34
35
36
37
# Program for keeping an account of
# withdrawal and deposits in a bank using OOP
class bank:
# Instance Attribute : name of owner and current balance
def __init__(self, owner, balance):
self.owner = owner
self.balance = balance
# magic_method: string
def __str__(self):
return f"Account owner: {self.owner}\nAccount balance: ${self.balance}"
# Instance Method : making a deposit
def deposit(self, depo):
self.balance = self.balance + depo
print("Deposit of $" + str(depo) + " Accepted")
# Instance Method : making a withdrawal
def withrdrawal(self, withdraw):
self.balance = self.balance - withdraw
if self.balance >= 0:
print("Withdrawal of $" + str(withdraw) + " Accepted")
else:
print("Insufficient Funds for withdrawal")
# driver program
acct1 = bank("Jose", 100)
print(acct1)
print(acct1.owner)
print(acct1.balance)
acct1.deposit(50)
acct1.withrdrawal(100)
acct1.withrdrawal(150)