Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Implement a class called Hurricane that implements the Comparable interface.(Don's forget to use generic notation.) Your class should have three private instance variables String

image text in transcribed
1. Implement a class called Hurricane that implements the Comparable interface.(Don's forget to use generic notation.) Your class should have three private instance variables String name; int windspeed: /measured in miles per hour int rainfall: I measured in inches per hour Provide a public constructor which allows the user to specity the name, windSpeed, and rainfall values as arguments. . Write getters for all three instance variables. .The "natural order" for Hurricanes should be based on their windspeeds. Write an equals method that is compatible with your compareTo method. (That means that compareTo returns O whenever Hurricanes are considered equal and vice versa. This is usually recommended when implementinga Comparable class.) Write a series of JUnit tests to verify that your compareTo and equals methods are working correctly 2. 3. Write two classes implementing the Comparator interface. (These will be used to compare Hurricanes, so be sure to use the proper generic notation.) The first one will be called NameComparator, the second one will be called RainfallComparator. The NameComparator will order hurricanes according to the alphabetical order of their names. The RainfallComparator will order hurricanes according to the rainfall amount. 4. Write more JUnit tests to check if these two comparators are working properly. 5. Write a separate class called Driver containing a main method which does the following a random number generator to initialize the windspeeds to values in the range of 70 to 200, also initialize the rainfall values randomly to values between 1 and5. a) Instantiate 100 hurricanes with the names "Hurricane1", "Hurricane2".." Hurricane100".Use b) Print out all the hurricanes three times i. Sorted by windSpeed i. Sorted by Name ili. Sorted by Rainfall

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Why might a firm begin paying stock dividends in the growth stage?

Answered: 1 week ago

Question

Explain how cultural differences affect business communication.

Answered: 1 week ago

Question

List and explain the goals of business communication.

Answered: 1 week ago