-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMethodOverriding_Polymorphism_oops.py
98 lines (60 loc) · 1.45 KB
/
MethodOverriding_Polymorphism_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
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
# class A:
# def show(self):
# print('Show A')
#
# class B(A):
# def show(self):
# print('Show B')
# print('show b 2')
#
# a=B()
# a.show()
#============================================================================
# class parent:
# parentAttr = 100
# def __init__(self):
# print('calling parent constructor')
# def parentMethod(self):
# print('calling parent method')
# def setAttr(self,attr):
# parent.parentAttr=attr
# def getAttr(self):
# print('parent attribute :',parent.parentAttr)
#
# class child(parent):
# def __init__(self):
# super().__init__()
# print('calling child constructor')
# def childMethod(self):
# print('calling child method')
# def parentMethod(self):
# print('overriden parent method') # method overiding
#
# c=child()
# c.childMethod()
# c.parentMethod()
# c.setAttr(200)
# c.getAttr()
#==============================================================================
# class A:
# def __init__(self):
# print('print A')
#
# class B(A):
# def __init__(self):
# super().__init__()
# print('print B')
# def show(self):
# print('anandhu')
#
# a=B()
# a.show()
#--------------------------------------------------------
class A:
def me(self):
print('Print class A')
class B:
def me(self):
print('Print class B')
x=B()
x.me()