From the course: Getting Started with Python Object Oriented Programming: A Hands-On Approach

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Challenge: Polymorphism

Challenge: Polymorphism

(upbeat music) - In the challenge for this chapter, you'll be given a base class, Animal, with a make_sound method. Your task will be to create two subclasses, Dog and Cat, each of which inherit from Animal, and you need to implement the make_sound method in each of these subclasses to print the sound specific to each animal. You can see the base class on the screen, so this is the Animal class, and it has a generic sound at the moment for make_sound. And this is going to become specific for each subclass. If you look in the repo in chapter 06_04, you'll find the start state for this challenge. It's also replicated in the start state for 06_03, just for consistency. But I recommend that you work on the 06_04 because then the end state for 06_04 will represent the end of the challenge. So either way, you've got poly_challenge.py. And you can see we have our Animal class, which you've seen, and then we have empty class definitions for Dog and Cat. And your task is to simply add one very…

Contents