Question: Answer the following using JAVA: Task 2.2 Write a Class Zoo, that contains . Data members: animals a collection of animals, the number is NOT

Answer the following using JAVA:

Answer the following using JAVA: Task 2.2 Write a Class Zoo, that

Task 2.2 Write a Class Zoo, that contains . Data members: animals a collection of animals, the number is NOT FIXED, you can add a new animal or remove one from it. Methods: Default constructor Constructor with all data members Copy bonstructor int countAnimals(String type) count in the zoo, how many animals belong to a certain type void updateValidTypes go through all animals in the zoo and check if there is a valid type in the ArrayList from which no animals in the zoo belong to that type. If so, remove the type from the valid type ArrayList. boolean isGender Balanced(String type) check if, for a specific type, the difference between the number of female and number of male is less than 20% of the total number of animals of that type. void removeOldest(String type) first check if the type is valid or not, if it is valid, then remove the oldest animal(s) of a certain type from the animals (if two animals have the same age, remove both), it calls updateValidTypes() in the end. Task 2.2 Write a Class Zoo, that contains . Data members: animals a collection of animals, the number is NOT FIXED, you can add a new animal or remove one from it. Methods: Default constructor Constructor with all data members Copy bonstructor int countAnimals(String type) count in the zoo, how many animals belong to a certain type void updateValidTypes go through all animals in the zoo and check if there is a valid type in the ArrayList from which no animals in the zoo belong to that type. If so, remove the type from the valid type ArrayList. boolean isGender Balanced(String type) check if, for a specific type, the difference between the number of female and number of male is less than 20% of the total number of animals of that type. void removeOldest(String type) first check if the type is valid or not, if it is valid, then remove the oldest animal(s) of a certain type from the animals (if two animals have the same age, remove both), it calls updateValidTypes() in the end

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!