dogs
class Dog:
def bark(self):
print "woof"
def wag(self):
print "wag wag wag"
class Dachshund(Dog):
def __init__(self):
self.height = 1
self.numberEars = 2
def dig(self):
print "dig dig dig"
def bark(self):
print "arf arf"
class Collie(Dog):
def rescue(self, person):
print "Come quickly, " + person + " fell down the mineshaft"
def dogShow():
bibi = Dachshund()
bibi.bark() # Should sound like "arf arf"
lassie = Collie()
lassie.bark() # Should sound like "woof"
bibi.dig() # Works ok.
lassie.rescue("Timmy") # Should do a Lassie-type thing
lassie.dig() # Should fail with an error. Dig is not something Collie's do.
Link to this Page