Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help with this programming homework. language is java Question Create the following classes: Write a Class Animal, that contains - Data members : name

please help with this programming homework. language is java image text in transcribed
image text in transcribed
image text in transcribed
Question Create the following classes: Write a Class Animal, that contains - Data members : name gender age type types A static ArrayList that holds all legal types - Originally only contains "Cat", "Dog", and "Monkey", but the list can be expanded or shortened in the future. - Methods: Default constructor - Constructor with all data members (except ArrayList) - Copy constructor boolean istypeValid(String type) equals() tostring() Example: Name : Copain Gender : Male Age : 5 Type : Dog getters and setters - You should use isTypeValid() in setType() and constructor(s) ite a Class Zoo, that contains - Data members: 0 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 constructor - int countAnimals(String type) - count in the zoo, how many animals belong to a certain type - ArrayList 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. Return an ArrayList of the removed types boolean isGenderBalanced(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. - Animal 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 then calls updateValidTypes() and returns the oldest Animal. equals() () xample: and setters

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

What is the USA Principle? What does each of the letters stand for?

Answered: 1 week ago

Question

Describe ERP and how it can create efficiency within a business

Answered: 1 week ago

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

2. Define communication.

Answered: 1 week ago