Create a GUI based program that reads in from Wilmington NC 100 year Hurricane Data to create Hurricane objects with the following instance data:
| YEAR | MONTH | STORM ID | STORM NAME | PRESSURE(MB) | WIND SPEED(MPH) | CATEGORY |
|---|
Use a naming convention that clearly identifies the purpose of each class, method, and field. Some methods and fields should be static to ensure the desired behavior, i.e. a sortField should be common to all instances. Your Hurricane objects must implement the Comparable interface. The compareTo method should be written to compare by any of the object's fields with at least three fields concatenated to break ties, except in the case of the unique ID where there should be no ties. Compare by category would compare category, year, then name. Compare by wind speed would compare wind speed, year, then name.
Your Hurricane objects must override the toString method to display each of the fields in the order shown. The fields should be formatted (padded with leading blanks so as to each take up the same amount of space as its respective heading. Do not display any fields other than those listed above.
When adding Hurricane objects to the Hurricane array only unique storm ids may be used. The data provided lists multiple instances of an id, but your array should contain only that id with the highest wind speed1.
Your GUI should display the field table above, with hurricanes listed below. Develop menus and menu items that include
Your GUI should have an analyses pane (JLabel) that answers the questions Which month has the most H5, H4, H3, H2, and H1 category hurricanes.
Data is based on a query of http://hurricane.csc.noaa.gov/hurricanes/ for all category H1-5 hurricanes within 65 nautical miles of zip code 28403 from 1903-2003.
Discussion:
As for the rest of the details, they are up to you.
//temp is an array of Hurricanes
each with unique ID but not necessarily the highest windspeed and category for
each
// see October 1, code Test1.java
for tips on creating temp[] with this precondition
//hurricanes is presorted so ids are sequential (should already be sorted by
year and ID)
//in the outer loop below cycle through temp and in the inner loop -compare to
hurricanes with same id
int maxSpeed, maxIndex = 0;
boolean haveUpdate = false;
for (int i = 0, j = 0; i < temp.length; i++) {
maxSpeed = temp[i].getWindSpeed();
for(; j < hurricanes.length &&
temp[i].getID().equals(hurricanes[j].getID()); j++) {
if (hurricanes[j].getWindSpeed() > maxSpeed) {
haveUpdate = true;
maxIndex = j;
}
}
if (haveUpdate) {
temp[i] = hurricanes[maxIndex];
haveUpdate = false;
}
}
hurricanes = temp;