Answered step by step
Verified Expert Solution
Question
1 Approved Answer
File Edit Format View Help You will need to create a class that implements the iAnimal interface as described in the discussion Zoo Animals and
File Edit Format View Help You will need to create a class that implements the iAnimal interface as described in the discussion Zoo Animals and download at least one class by a fellow classmate for a different animal than your own from that discussion. Modify the animal classes that you will use for this project so they implement Java's comparator interface You will also need a Foothill (Main) Class that will provide a user interface for this application. Based on user interaction, you will need to perform the tasks listed below. These tasks can be performed in one or more methods as needed. The Foothill (Main) class should have one or more methods that handle these tasks: Create a new instance (object) of each of the animal classes and pass the user input as arguments to the object's mutator methods to set the private instance data for the appropriate animal class. Create an ArrayList of type iAnimal and add the new instance created in task 1 to the ArrayList. Before adding the instance to the ArrayList you must: Call the compareTo method (see Java's comparator interface) for the new animal's instance to compare that new instance to each of the instances already in the ArrayList (use a loop or recursion for this) If the ArrayList is empty, or if none of the instances are identical to the new instance, insert the new instance into the ArrayList. If the new instance is identical to any of the instances already in the ArrayList, display an error message and do not insert the new instance. When testing, add multiple instances of your animal's class and multiple instances of the class you borrowed from the discussion to the ArrayList as described above. Because you are working with more than one class, you can decide how to determine which class to use based on user input, but the goal is to create an instance of the class that matches the type of animal entered by the user Use a loop to iterate through the ArrayList and display all of the data for each instance in the ArrayList using accessor or Tostring methods. Feel free to add whatever you need for testing purposes. You can also make changes to your classmate's class as needed. You do not need to include the output with your submission, but please add a comment to let me know which type of application you selected interface iAnimal{ public String getAnimaltype); public int getIdTag(); public void setIdTag(int anIdTag); public int getMinTempreture(); public int getMaxTempreture(); class Tiger implements iAnimal private int Id; private String type; private int minTemp , maxTemp; public Tiger ) { id = 0; type -"Tiger"; maxTemp -32; public string getAnimaltype() return type; public int getIdTag() { return Id; public void setIdTag(int anIdTag) { Id anIdTag; public int getMinTempreture() return minTemp; public int getMaxTempreture() return maxTemp; public class Narwhal implements iAnimal int minTemp 53; int maxTemp -55; int IdTag; string animalName "Narwhal" public String getAnimalType) return this.animalName; public int getIdTag) return IdTag; public void setIdTag(int anldTag) this.IdTag -anIdTag; public int getMinTemperature) return this.minTemp;) public int getMaxTemperature) return maxTemp
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