Question: Write a java programPart 1 . Implement the classes Animal and Zoo as presented in the following UML diagramZoo - animals: Animall ] + Zoo
Write a java programPart Implement the classes Animal and Zoo as presented in the following UML diagramZoo animals: AnimallZoosetOfAnimals: StringgetAnimals: AnimalcountCatsO: int count Young: int toString: StringAnimaltype: Stringcolor : Stringage: intAnimal type: String, color: String, age: int getters is YoungO: booleanThe class Animal contains:Fields:The animal's type: must be cat or bird.The animal's color.o The animal's age in months.Methods:Allarguments constructor. All gettersThe boolean method isYoung of the class Animal: checks if an animal is young or not. An animal is young if it is a cat with age greater than months, or if it is a bird with age greater than months.The class Zoo contains:Fields:An array of animals.Methods:A constructor that creates a Zoo abject. The constructor takes as parameter a String formed of a set of animals' descriptions separated by a dash as in the following example:black cat red bird white cat The constructor extracts the information about each animal type color, age and fill the array animals.We assume that each animal's description follows the format: color space typespaceage example black cat The getter of the array animalsA method countCats that returns the number of cats in the zoo.A method count Young that returns the number of young animals in the zoo.A method toString that prints the information about the Zoo as in the following example:The Zoo contains cats and birds.Part Implement a driver class to test the classes in Part as follows:Read from the user a String formed of animals' descriptions and create a Zoo objectDisplay the count of young animals in the Zoo.Display the information about the Zoo.Without adding extra methods to the classes Zoo and Animal, write in the driver the code to search for and display the number of red animals in the Zoo.Without listing
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
