Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 and 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.
equalsObject obj method:
Override the equalsObject obj method.
Returns True if two animals have the same speed within mph; 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 AnimalListtxt 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
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