Question: Python Assignment: Create a Zoo populated with Animals held in Enclosures. Each class should be contained in its own file. Here are the features for

Python Assignment:

Create a Zoo populated with Animals held in Enclosures. Each class should be contained in its own file. Here are the features for each of the classes:

The Zoo should hold a 3x3 grid of Enclosures. The grid should be constructed of a list, 3 elements long, holding 3 lists, each 3 elements long.

The Zoo should support a visit() method that traverses the grid and prints off each Enclosure contained in it.

Enclosures should hold a list of animals occupying it and a maximum number of Animals allowed in it.

Enclosures should include an add_animal(a, n) method to add n Animals to it. If the Animals are not allowed in the enclosure, the method should return 0, otherwise, return the number of Animals added (up to the maximum).

Enclosures should include a del_animal(a, n) method to delete n Animals from it. If that number of Animals are present, the list of Animals should be decreased by that many, and number of of Animals deleted should be returned. If there are not that number of Animals present, delete as many as possible, and return that number.

There should be Aquatic, Aviary, and Land Enclosures, inheriting from a parent Enclosure class. Aquatic Enclosures can hold 6 aquatic Animals, Aviary Enclosures can hold 24 aviary Animals, and Land Enclosures can hold 12 land Animals.

Enclosures should support the __str__() method that prints off the number of animals, their names, and some descriptive phrase about what they're doing in the Zoo. For example, "You look at the Aquatic Enclosure and see 2 Dolphins jumping and 3 Whales swimming and 1 Shark eating." The verb or descriptive phrase for each animal should be obtained by printing the animal (i.e. using its __str__() method).

Animals should have a type property that is either Aquatic, Aviary, or Land.

Animals should have a verb or descriptive phrase property. The __str__() method should return something compatible with how you set up the enclosure.

When exercise1.py is ran, it should create a full Zoo. All 9 spots are filled with Enclosures with their maximum number of animals. You may choose the mix of Enclosures, just be sure to use all 3 types.

Then call the visit() method. It should then empty the Zoo of all Animals and call the visit() method again.

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 Databases Questions!