Question: Students will implement the animal library with the following specification: Animal.java: Constructor: Create a constructor that accepts a String for the name and an int

Students will implement the animal library with the following specification:
Animal.java:
Constructor:
Create a constructor that accepts a String for the name and an int for the topSpeed.
Getters and Setters:
Declare getters and setters for both name and topSpeed.
Ensure that the speed range is between 0 and 70 inclusive.
If topSpeed is outside this range, display an error message.
toString() method:
Implement a toString() method that returns a string representation of the animal's name and speed.
equals(Object obj) method:
Override the equals(Object obj) method.
Returns True if two animals have the same speed within 2mph; otherwise, return False.
Use the Math.abs() method for absolute value calculations.
AnimalBook.java:
Declare a private ArrayList variable to store Animal objects.
The constructor takes a text file as a parameter and initializes the array list by loading information from the AnimalList.txt file.
The toString() method returns a string representation of all elements in the array list.
The findAnimals() method searches for animals in the animal library whose speeds are equal to the parameter value by utilizing the equals method in the Animal class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!