Question
1.Define a class called Animal that abstracts animals and supports three methods: setSpecies(species): Sets the species of the animal object to species. setLanguage(language): Sets the
1.Define a class called Animal that abstracts animals and supports three methods:
setSpecies(species): Sets the species of the animal object to species.
setLanguage(language): Sets the language of the animal object to language.
speak(): Prints a message from the animal as shown below.
The class must support supports a two, one, or no input argument constructor.
Then define Bird as a subclass of Animal and change the behavior of method speak() in class Bird.
>>> snoopy = Animal('dog', 'bark')
>>> snoopy.speak()
I am a dog and I bark.
>>> tweety = Animal('canary')
>>> tweety.speak()
I am a canary and I make sounds.
>>> animal = Animal()
>>> animal.speak()
I am a animal and I make sounds.
>>> daffy = Bird()
>>> daffy.speak()
quack! quack! quack!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started