Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

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