forked from souravjain540/Basic-Python-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
banking_system.py
70 lines (61 loc) · 1.89 KB
/
banking_system.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# TODO:
# Parent Class : User
# Holds details about an user
# Has function to show user details
# Child Class : Bank
# Stores details about the account balance
# Stores details about the amount
# Allows for deposit, withdraw and view balance
# Parent Class
class User():
def __init__(self,name,age,gender):
self.name = name
self.age = age
self.gender = gender
def show_details(self):
print(f"""
Personal Details
-------------------------
Name : {self.name}
Age : {self.age}
Gender : {self.gender}
""")
# arjun = User('Arjun',20,'Male')
# print(arjun)
# arjun.show_details()
# Child Class
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.amount
print(f"Successfully Deposited : ${self.amount}")
print(f"Current Balance : ${self.balance}")
print()
def withdraw(self,amount):
self.amount = amount
if self.amount < self.balance:
self.balance -= self.amount
print(f"Successfully Withdrawn ${self.amount}")
print(f"Current Balance : ${self.balance}")
print()
else:
print("Not Enough Balance!!!")
print(f"Current Balance : ${self.balance}")
print()
def view_balance(self):
self.show_details()
print(" -------------------------")
print(f" Current Balance : ${self.balance}")
print()
#--------------------------------------------------
sbi = Bank('Akshay',20,'Male')
print(sbi)
# sbi.show_details()
# sbi.view_balance()
# sbi.deposit(100)
sbi.deposit(1000)
sbi.withdraw(100)
# sbi.withdraw(1100)