Question: Create a simple class hierarchy to represent animals in a zoo. You ll define a base class Animal, and several child classes like Bear, Elephant,
Create a simple class hierarchy to represent animals in a zoo. Youll define a base class Animal, and several child classes like Bear, Elephant, and Penguin, each inheriting common functionality from the parent class and overriding or extending specific methods.
Your Animal class should contain the following methods & Attributes which are accessible from a menu.
Attributes: Each animal should have a name and a species
makesound: Returns a "generic animal sound" each subclass should overriding this to fit its animal
info: This will return a formatted string the animals name, species, and sound
Animal subclasses. You should include a subclass for Bear, Elephant, & Penguin or more for extra credit Each subclass inherits from the animal class and adds on to it or overrides methods.
Bear: The bear class contains an attribute for Fur Color stored as a string ex Brown, White, Black & White, etc The sound method should be overridden to reflect a bears "roar" sound. And the info method should also be overridden to include the Fur color information.
Elephant: The elephant class contains an attribute for Weight stored as a float representing weight in kilograms The sound method should be overridden to reflect a elephants "trumpet" sound. And the info method should also be overridden to include the Weight information.
Penguin: The penguin class contains an attribute for Height stored as a float representing height in feet The sound method should be overridden to reflect a penguin "squawk" sound. And the info method should also be overridden to include the Height information.
In your main create a simple menu to add animals to the zoo represented by a list, print all the animals in the zoo, and print all the animals of a single type Bears Elephants, Penguins
Example Output:
Zoo Menu
add animals
print all
print specific
input:
Add Menu
add bear
add elephant
add penguin
input:
input Name: Kowalski
input species: Adlie
input height in ft:
Zoo Menu
add animals
print all
print specific
input:
print Menu
print bear
print elephant
print penguin
input:
Kowalski is a penguin of the Adlie species and stands at a height offt
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
