Answered step by step
Verified Expert Solution
Link Copied!

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions

Question

=+j on to staff their operations in the global marketplace.

Answered: 1 week ago