-
Notifications
You must be signed in to change notification settings - Fork 67
/
Banking_OOPS.py
38 lines (35 loc) · 1.11 KB
/
Banking_OOPS.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
38
class User():
def __init__(self,name,age,gender):
self.name = name
self.age = age
self.gender = gender
def show_details(self):
print("Personal Details\n")
print("Name: ",self.name)
print("Age: ",self.age)
print("Gender: ",self.gender)
class Bank(User):
def __init__(self,name,age,gender):
super().__init__(name,age,gender)
self.balance = 0
def deposit(self,amount):
self.amount = amount
self.balance = self.balance + amount
print("Amount balance updated : ",self.balance)
def withdraw(self,amount):
self.amount = amount
if(self.amount > self.balance):
print("Insufficient Balance.")
else:
self.balance = self.balance - self.amount
print("Current Balance: ", self.balance)
def view_balance(self):
self.show_details()
print("Current Balance: ", self.balance)
Customer = Bank("Vatson",20,"Male")
Customer.show_details()
Customer.deposit(1000)
Customer.deposit(500)
Customer.withdraw(2000)
Customer.withdraw(600)
Customer.view_balance()