28 lines
419 B
Python
28 lines
419 B
Python
|
#: generics/DogsAndRobots.py
|
||
|
|
||
|
class Dog:
|
||
|
def speak(self):
|
||
|
print("Arf!")
|
||
|
def sit(self):
|
||
|
print("Sitting")
|
||
|
def reproduce(self):
|
||
|
pass
|
||
|
|
||
|
class Robot:
|
||
|
def speak(self):
|
||
|
print("Click!")
|
||
|
def sit(self):
|
||
|
print("Clank!")
|
||
|
def oilChange(self):
|
||
|
pass
|
||
|
|
||
|
def perform(anything):
|
||
|
anything.speak()
|
||
|
anything.sit()
|
||
|
|
||
|
a = Dog()
|
||
|
b = Robot()
|
||
|
perform(a)
|
||
|
perform(b)
|
||
|
#:~
|