Question: Points Possible: 4 0 This problem will allow you to demonstrate your understanding of Python classes and objects, inheritance, and polymorphism by creating a simple

Points Possible: 40
This problem will allow you to demonstrate your understanding of Python classes and objects,
inheritance, and polymorphism by creating a simple Zoo Management System. You will add the
functionality of a menu and the ability to accept user input when adding, creating, and listing
animals in the Zoo.
Instructions:
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:
a. 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.
b. 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.
c. 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.
d. 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.
e. 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.
f. 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.
g. Comment your code. Your comments should explain clearly what each part of the
code does.
h. Include a main loop that is automatically called if the script is not imported by
another script as a module.
i. Hint: You can use the input() function to get input from the user, and a loop to
keep showing the menu until the user decides to quit. You may want to use a
dictionary to map from animal types entered by the user to your animal classes.
When your program runs, it should match the expected output below exactly. Go back
in and put in labels as needed.
Shall
*Run PS6_P4_solution.py
mm=== Sparky's Zoo Managenent Systen mm=m
Add Animal
Renove Animal
List Animals
Quit
Choose an option: 1
Enter the animal type (Lion, Elephant): Lion
Enter the animal's name: Oliver
Enter the animal's age: 4
Lion has been added to the zoo.
Add Animal
Renove Animal
List Animals
Quit
Choose an option: 1
Enter the animal type (Lion, Blephant); Blephant
Enter the animal's name; Dumbo
Enter the animal's age: 11
Elephant has been added to the zo0.
Add Animal
Renove Animal
List Animals
Quit
Choose an option: 3
Wame: Oliver, Age: 4, Species: Lion, Sound: Roar
Name: Dunbo, Age: 11, Species: Elephant, Sound: Trumpet
Add Animal
Remove Animal
List Animals
Quit
Choose an option:
Choose an option: 1
Enter the animal type (Lion, Elephant): Tiger
Invalid animal type.
Add Animal
Renove Animal
List Animals
Quit
Choose an option:
Choose an option: 2
Enter the animal's name to renove; Oliver
oliver has been removed from the zoo.
Add Animal
Renove Animal
List Animals
Quit
Choose an option: 3
Name: Dumbo, Age: 11, Species: Blephant, Sound: Trumpet
Add Animal
Renove Animal
List Animals
Quit
Choose an option: 4
Points Possible: 4 0 This problem will allow you

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!