-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython oops.py
146 lines (77 loc) · 2 KB
/
python 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#############################################
"""
Python OOPS
"""
##############################################
# class and object
# class is the instance of the object.
# object is the template of the class.
# for e.g.,
"""
if class is a blueprint of home designing , we can do that blue print with anything , we can make many houses.. here houses are considred as object.
for e.g.,
SUPER MARIO GAME
here many enemies are there
turtle
chain comp
boo
goomba
dragon
here these enemies have unique power of attacking ...
that are size , postion , effective , power , dead === these are controls by class
and , the differenet enemies are mad up by this things is called object...
"""
############################
"""
OOPS PRINCIPLES
"""
#############################
"""
encapsulation
abstraction
inheritance
polymorphism
"""
# encapsulation ()
"""
encapsulation
* class with data we can write in same class
* hiding data . prevent direct access from outside
access through methods
* getter * setter
* retrieve infromation * modifier infromation
"""
# abstraction ()
"""
* only show essential detail
* hide all other details
* interface * implementation
* shown outside details (class) * hidden from outside details (class)
"""
# inheritance ()
"""
* allow classes to use .. data & method from another class
* hierarchy .
* super class
/ | \
/ | \
* class 1 * class 2 * class 3
sub class inherit from super class
* access modifiers
public , private , protected
"""
# polymorphism ()
"""
* ability of methods to take more than one form
2 types
* dynamic
* static
# dynamic ()
occurs during run time
if both super class and sub class have same method means ..., here they use polymorphism
# static ()
occurs during compile - time
function or method overloading
same class with same function we write , but different argument ...
"""
####################################################################