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:
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 makesound 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 addanimal and removeanimal. Also, add a method
getanimals 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 makesound 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 makesound 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 PSPsolution.py
mm Sparky's Zoo Managenent Systen mmm
Add Animal
Renove Animal
List Animals
Quit
Choose an option:
Enter the animal type Lion Elephant: Lion
Enter the animal's name: Oliver
Enter the animal's age:
Lion has been added to the zoo.
Add Animal
Renove Animal
List Animals
Quit
Choose an option:
Enter the animal type Lion Blephant; Blephant
Enter the animal's name; Dumbo
Enter the animal's age:
Elephant has been added to the zo
Add Animal
Renove Animal
List Animals
Quit
Choose an option:
Wame: Oliver, Age: Species: Lion, Sound: Roar
Name: Dunbo, Age: Species: Elephant, Sound: Trumpet
Add Animal
Remove Animal
List Animals
Quit
Choose an option:
Choose an option:
Enter the animal type Lion Elephant: Tiger
Invalid animal type.
Add Animal
Renove Animal
List Animals
Quit
Choose an option:
Choose an option:
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:
Name: Dumbo, Age: Species: Blephant, Sound: Trumpet
Add Animal
Renove Animal
List Animals
Quit
Choose an option:
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
