Created
March 2, 2016 08:26
-
-
Save drhanlau/476c09f90a81b178eab1 to your computer and use it in GitHub Desktop.
Duck Typing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Duck: | |
def quack(self): | |
print("Quaaaaaack!") | |
def feathers(self): | |
print("The duck has white and gray feathers.") | |
class Person: | |
def quack(self): | |
print("The person imitates a duck.") | |
def feathers(self): | |
print("The person takes a feather from the ground and shows it.") | |
def name(self): | |
print("John Smith") | |
def in_the_forest(duck): | |
duck.quack() | |
duck.feathers() | |
def game(): | |
donald = Duck() | |
john = Person() | |
in_the_forest(donald) | |
in_the_forest(john) | |
game() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment