Skip to content

Instantly share code, notes, and snippets.

@antiface
Forked from jhamrick/pets.py
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antiface/510045affa0a91cff867 to your computer and use it in GitHub Desktop.
Save antiface/510045affa0a91cff867 to your computer and use it in GitHub Desktop.
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")
self.hates_dogs = hates_dogs
def hatesDogs(self):
return self.hates_dogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment