codingpython
Functional-style method dispatch
Given the following class Dog, create an instance of a Poodle and a Lab by creating instances of Dog and passing in the custom functionality to the Dog functions. bark() should print the Dog’s name and bark_age() should print the Dog’s age. The name and age for the Poodle and Lab should be encapsulated within functions that are passed in to bark() and bark_age(). All bark() and bark_age() should do is take in these functions and invoke them. This is demonstrating how to achieve polymorphic behavior via functional-style programming, as no name or age state is encapsulated in the Dog class. The names and ages of the Dogs are specified below. After the functions are implemented, call bark() and bark_age() for the Poodle and Lab.
python'''
Poodle
name: Dave
age: 10
Lab
name: Bob
age: 8
'''
class Dog:
def bark(self, func):
...
def bark_age(self, func):
...