Home / Challenges / Animal Sounds with Inheritance

Animal Sounds with Inheritance

Medium
Create a base class Animal with a method speak() that returns "..." . Create subclasses Dog and Cat that override speak() to return "Woof!" and "Meow!" respectively. Write a function make_sound(animal) that calls and returns animal.speak(), demonstrating polymorphism.

Input

No input — create instances of Dog and Cat.

Output

The sounds returned by each animal.

Example

Input
make_sound(Dog()), make_sound(Cat())
Output
Woof!
Meow!
15 XP on solve Back to lesson

Your Solution

Output
Click "Run" to execute your code...

Log in to submit your solution and earn XP.