Question: In Python: 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):
In Python:
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
Get step-by-step solutions from verified subject matter experts
