
CS Java Program (NEED HELP WITH THE ACTUAL CODING PART):
For this project, you will create an application for a zoo.
You will need to create a class that implements the iAnimal interface (provided below), and use one other class for an additional animal that implements the iAnimal interface as well (provided below). Modify the animal classes that you will use for this project so they implement Java’s comparable or comparator interface.
You will also need a Main Class that will provide a user interface for this application. This can be a console-based interface. Tasks can be performed in one or more methods as needed.
The 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 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.
Classes for iAnimal Interface:
public class Panda implements iAnimal {
private String animalType = “Panda";
private int idTag;
private int minTemperature = 30;
private int maxTemperature = 80;
public String getAnimalType() {
return animalType;
}
public int getIdTag() {
return idTag;
}
public void setIdTag(int anIdTag) {
idTag = anIdTag;
}
public int getMinTemperature() {
return minTemperature;
}
public int getMaxTemperature() {
return maxTemperature;
}
}
public class Tiger implements iAnimal {
private String animalType = “Tiger";
private int anIdTag;
private int minTemp = 44;
private int maxTemp = 77;
public String getAnimalType() {
return "Hamster";
}
public int getIdTag() {
return anIdTag;
}
public void setIdTag(int anIdTag) {
this.anIdTag = anIdTag;
}
public int getMinTemperature() {
return minTemp;
}
public int getMaxTemperature() {
return maxTemp;
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- what are the positives and negatives of the two designs attached. The Java code next to each design shows an example of how the constructors are implemented in the subclasses. Constructor code for the other two other subclasses is same as the Bipedal constructor in each design (except the number of legs value). designs attachedarrow_forwardThe correct version of the code we are testing is in a module named piggy. This module simulates a ceramic piggy bank. It works like this: initially it starts off containing no coins and having no value. As you add coins, the number of coins in the bank increases, and also the total value of the coins increases. Of course, it is limited in size, so there is a maximum number of coins it can hold (we are assuming that all coins take up the same space regardless of their value). Once it reaches that maximum, you can't add any more. Finally, it can be smashed to get the money out. But after it is smashed, it contains no coins and you can't add any more, until you re-initialize the module by calling start again. The module has the following functions: start(max) - initializes the piggy bank so it can hold the given maximum number of coins. Initially it contains no coins and has zero value and is not smashed. add_coin(coin_value) - adds a coin with the given value to the piggy bank, unless…arrow_forwardI am a freshman and new to Java. I am making an Elevator Simulation as my project but don't know how it works. I tried to upload the code I had but I was having format problem. So on the bottom, I wrote some classes and wrote what I am planning to write inside. It would be helpful if any of you can tell me what I need to improve or add. Instructions: The goal is to create an elevator simulation using object-oriented programming and polymorphism. The simulation involves 8 elevators, each of which can be one of 4 types with different percentages of requests, and 4 types of passengers with different percentages of requests. The elevator types include Standard, Express, Freight, and Glass elevators, while the passenger types include Standard, VIP, Freight, and Glass passengers. The simulation starts with a specified number of passengers added to different floors of the building, and during the simulation, the elevators will move up and down the building, picking up and dropping off…arrow_forward
- I need help with completing my Java programming project. I will be using the software Eclipse for this project so if you could also guide me through the project like labeling what is supposed to be in whatever "4 java files" or what section is what so I'm not trying to guess around, that would be great. Thank youarrow_forwardJava Programingarrow_forwardJava program I need help creating a program that creates these two Christmas trees. It has a method that accepts two parameters (one for the number of segments and one for the height of each segment). The left tree has 3 segments with a height of 4 and the right one has two segments with a height of 5. If you could explain it, that would be great, I really want to understand how you do it.arrow_forward
- Computer Science Create a UML diagram of the following methods & classes (java language) using LucidApp. Class Name Method Description Calculation Multiply Multiplies two variables with data type double and returns the product Returns the area of the Rectangle using the method "Multiply" of the "Calculation" class in the calculation Rectangle Area Rec_Prism Volume - Returns the volume of a Rectangular Prism - Inherits class "Rectangle" and utilizes the method "Area" in the calculation Triangle Returns the area of the Triangle using the method “Multiply" of the "Calculation" class in the calculation Area Tri_Prism Volume Returns the volume of a Triangular Prism - Inherits class "Triangle" and utilizes the method "Area" in the calculation Reflexive Power - Inherits class "Calculation" - Returns the product of a number multiplied by itself based on the exponent - Requires two input parameters: a = the number b= the exponent - Calls the method "Multiply" to perform the multiply operation.…arrow_forwardWhat is the purpose of an interface? A. To define a set of variables. B. To make it so we don't have to write as much javadoc. C. To define a type and all of its supported operations. D. To minimize code duplication.arrow_forwardIn JavaScript, how are an object and an interface related to each other? a. The object’s interface consists of the code and data needed for that object. b. An object’s interface is analogous to a pocket calculator’s inner workings. c. Built-in JavaScript objects do not require an interface, but custom objects do. d. An interface allows another program to access an object’s properties and methods.arrow_forward
- For this assignment, create a child class of car that creates a car of a randomly generated color. Using the existing car classes, add code to add 20 colored cars to the existing pane in 20 visible, random locations. You will end up with 4 classes: CarViewer.java CarComponent.java Car.java (unchanged from Chapter 3) ColorCar.java (extends Car)arrow_forwardExercise 1 - Number Guessing Game Make a new Java Project called Lab2. Within it, add a new class with the main method called NumberGuessGame. Inside the main method, implement a number guessing game, which will work by generating a pseudorandom number in the range of 0 to 100 (inclusive, so both 0 and 100 should be possible), then asking the user to enter a number that will be their guess. If the two match, display an appropriate message. Otherwise, display either "greater" or "lesser", depending on whether the pseudorandom number is greater than or less than the number entered.arrow_forwardWrite a GUI program on Java to play dice games between two players. The game starts with a coin toss determining who starts. Players roll the dice in turn to get the combination of the two dice. In each round the player with the lowest combination loses a “life” – each player starts with six lives. When the count of lives goes down to 0, the player is out of the game. If the player is not satisfied with the result of rolling, he/she may re-roll. If he/she wishes re-roll, the result of the second is the final.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





