Create a class Bird
with a method fly()
. Implement child classes Sparrow
and Ostrich
that override the fly()
method, where the Ostrich
class should print a message that it cannot fly.
Example 1:
Input: Sparrow
Output: "Sparrow is flying"
Example 2:
Input: Ostrich
Output: "Ostrich cannot fly"