-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoly.py
More file actions
22 lines (22 loc) · 715 Bytes
/
poly.py
File metadata and controls
22 lines (22 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Here we cover all the topic about polymorphism
class payment:
def __init__(self,amount):
self.amount = amount
def pay(self):
print("Payment successful")
class CreditCard(payment):
def __init__(self,amount,credit_card_number):
super().__init__(amount)
self.credit_card_number = credit_card_number
def pay(self):
print("Payment successful")
class DebitCard(payment):
def __init__(self,amount,debit_card_number):
super().__init__(amount)
self.debit_card_number = debit_card_number
def pay(self):
print("Payment successful")
obj = CreditCard(1000, "1234567890123456")
obj.pay()
obj = DebitCard(1000, "1234567890123456")
obj.pay()