-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreakingClass.py
More file actions
40 lines (36 loc) · 985 Bytes
/
breakingClass.py
File metadata and controls
40 lines (36 loc) · 985 Bytes
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 Animal(object):
def __init__(self, name):
self.name = name
self.health = 100
self.fart = "loud"
def walk(self):
self.health -= 1
return self
def run(self):
self.health -= 5
return self
def displayHealth(self):
print self.name, self.health
return self
animal = Animal('ladsjfklfasjdk')
animal.walk().walk().walk().run().run().displayHealth()
class Dog(Animal):
def __init__(self):
self.health = 150
def pet(self):
self.health += 5
return self
jojo = Dog()
jojo.fart
class Dragon(Animal):
def __init__(self, name):
super(Dragon, self).__init__(name)
self.health = 170
def fly(self):
self.health -= 10
return self
def displayHealth(self):
print 'this is a dragon!'
super(Dragon, self).displayHealth()
fyordor = Dragon('fyordor')
fyordor.walk().walk().walk().run().run().fly().fly().displayHealth()