-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMagicFunctions2
40 lines (28 loc) · 1.02 KB
/
MagicFunctions2
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
class Dog():
colour="Brown"
#common for all variables in the same class
#activities=[]
# so if we want to avoid this condition , that all the actitivities get added to all the dogs then we have to add activitites to the constructor
def __init__(self,breed):
"""This is one of the first classes created by S.Prubhtej Singh"""
self.activities=[]
# now we see what activities we have assigned to various dogs they get only that.....
self.breed=breed
def addActivities(self,act):
self.activities.append(act)
def __secretActivity(self) :
print("Doing secret activity "+self.breed)
def doActivities(self):
print(self.breed)
print(self.activities)
self.__secretActivity()
d=Dog("German Shephard")
d2=Dog("Golden Retriever")
d.addActivities("high jump")
d.addActivities("roll over")
d2.addActivities("Loud barking")
d2.addActivities("strong")
d.doActivities()
d2.doActivities()
#d2.secretActivity()
Dog?