Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN JAVA PLZ 2. Create an Animal array with a size 5. a. Store the 5 different Animal objects from the Main class into the
IN JAVA PLZ
2. Create an Animal array with a size 5. a. Store the 5 different Animal objects from the Main class into the array. b. Create a method that prints out the contents of an Animal array. c. Using selection sort, sort the Animals in ascending order based on the number of legs. Use the method on your Animal array. d. Display the array of Animals. e. Using the improved linear search algorithm, create a method that will find an Animal object based on the number of legs. Your method should take in an Animal array and numOfLegs (key) as the parameters. If the Animal is found, return true, else, return false. \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Mammal } \\ \hline -eggLaying: boolean \\ -habitat: String \\ \hline +Mammal() \\ +Mammal(eggLaying:boolean, habitat:String, numOfLegs:int, diet: String) \\ +getEggLaying(: boolean \\ +getHabitat: String \\ +setEggLaying(boolean eggLaying) \\ +setHabitat(String habitat) \\ +toString0: String \end{tabular} \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Horse } \\ \hline -color: String \\ \hline +Horse(color: String) \\ + getColor(): String \\ +setColor(String color) \\ +equals(Horse horse): boolean \\ \hline \end{tabular}Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started