Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The zoo will have several animals, and each animal will have a name, age, and species. Moreover, each animal will have a method make_sound(), which

  1. The zoo will have several animals, and each animal will have a name, age, and species. Moreover, each animal will have a method make_sound(), which should return a string representing the sound it makes. Perform the following steps:
    1. 1. Create a Zoo class. This class should be able to store multiple animals. It should have methods to add_animal and remove_animal. Also, add a method get_animals that prints a list of all animals currently in the zoo, including their name, age, and species.
    2. 2. Create an Animal parent class. This class should have attributes for name, age, and species. Include a make_sound() method that returns a string representing the sound the animal makes.
    3. 3. Create two or more child classes that inherit from Animal (for example, Lion and Elephant - you get to choose the animal types). These child classes should override the make_sound() method to return a sound specific to the animal they represent.
    4. 4. Your program should be interactive. It should provide a menu to the user that allows them to add an animal to the zoo, remove an animal from the zoo, or list all animals in the zoo. The user should be able to keep using this menu until they decide to quit the program.
    5. 5. When adding an animal, your program should ask the user for the animal's name, age, and type. It should then create an object of the appropriate type, and add it to the zoo.
    6. 6. Ensure that your program handles errors appropriately. For example, it should not crash if the user tries to remove an animal that isn't in the zoo.
    7. 7. Comment your code. Your comments should explain clearly what each part of the code does.
    8. 8. Include a main loop that is automatically called if the script is not imported by another script as a module.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Advanced Accounting In Canada

Authors: Hilton Murray, Herauf Darrell

7th Edition

1259066487, 978-1259066481

More Books

Students also viewed these Programming questions

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago