23 lines
352 B
Python
Raw Normal View History

2015-05-18 23:05:20 -07:00
#: staticchecking/PetSpeak.py
2015-05-29 14:18:51 -07:00
# <20>2015 MindView LLC: see Copyright.txt
2015-05-18 23:05:20 -07:00
# Speaking pets in Python
class Pet:
def speak(self): pass
class Cat(Pet):
def speak(self):
print("meow!")
class Dog(Pet):
def speak(self):
print("woof!")
def command(pet):
pet.speak()
pets = [ Cat(), Dog() ]
for pet in pets:
command(pet)
#:~