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
make_sound: 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===
1) add animals
2) print all
3) print specific
=============
>>input: 1
.
===Add Menu===
1) add bear
2) add elephant
3) add penguin
=============
>>input: 3
>>input Name: Kowalski
>>input species: Adlie
>>input height (in ft): 1.5
.
===Zoo Menu===
1) add animals
2) print all
3) print specific
=============
>>input: 3
.
===print Menu===
1) print bear
2) print elephant
3) print penguin
=============
>>input: 3
Kowalski is a penguin of the Adlie species and stands at a height of1.5ft.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!