-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimal.py
More file actions
26 lines (23 loc) · 732 Bytes
/
animal.py
File metadata and controls
26 lines (23 loc) · 732 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
class Pet(object):
def __init__(self, name, species):
self.name = name
self.species = species
def getName(self):
return self.name
def getSpecies(self):
return self.species
def __str__(self):
return "%s is a %s" % (self.name, self.species)
class Dog(Pet):
def __init__(self, name, chases_cats):
Pet.__init__(self, name, "Dog")
self.chases_cats = chases_cats
def chasesCats(self):
return self.chases_cats
class Cat(Pet):
def __init__(self, name, hates_dogs):
#Pet.__init__(self, name, "Cat")
super(Cat, self).__init__(name, "Cat")
self.hates_dogs = hates_dogs
def hatesDogs(self):
return self.hates_dogs