Description
- Here is starter code:Â java
- Read over how interface Comparable works:
- javais interface Comparable with a detailed description of how it is implemented.
- Java API Interface Comparablehas even more details.
- Add interface java.lang.Comparableto the first line of your class HawaiiNativeBirds.
- For example:
class HawaiiNativeBirds implements java.lang.Comparable{ - Add the compareTo() method to class HawaiiNativeBirds to sort any data field that you wish. In other words, write a compareTo() method definition nested inside your class HawaiiNativeBirds that sorts one of the data fields of class HawaiiNativeBirds. Here are examples of compareTo() method definitions:
- To prevent the automatic output of the javaprogram, use this code before you sort: Sorting.display = false;
- Use the one of the methods from the javaprogram to sort your array of HawaiianTheme objects. In other words, in your main() method, write a method call from one of the sorting methods from the Sorting.java program. For example:
Sorting.selectionSort(arrayOfHawaiianThemeObjects);
Here are examples of sorting method calls:
Make sure to have comments and Javacoding in every method.
Sample output: with a different theme.
Display MarineMammalsOfHawaii array[] without initializing elements:
index  element
0Â Â Â Â null
1Â Â Â Â null
2Â Â Â Â null
3Â Â Â Â null
4Â Â Â Â null
5Â Â Â Â null
6Â Â Â Â null
7Â Â Â Â null
8Â Â Â Â null
9Â Â Â Â null
10Â Â Â Â null
11Â Â Â Â null
12Â Â Â Â null
13Â Â Â Â null
14Â Â Â Â null
15Â Â Â Â null
16Â Â Â Â null
17Â Â Â Â null
Read from input file: mammals2.csv
Display MarineMammalsOfHawaii array[] after initializing elements:
index  name                       population  length (meters) Genus species
0    Hawaiian monk seal              1100     2.40         Monachus schauinslandi
1    humpback whale                 10000    16.00         Megaptera novaeangliae
2    spinner dolphin                 3351     2.35         Stenella longirostris
3    common bottlenose dolphin        235     3.50         Tursiops truncatus
4    Risso’s dolphin                85000     4.00         Grampus griseus
5    rough-toothed dolphin         150000     2.83         Steno bredanensis
6    striped dolphin              2000000     2.60         Stenella coeruleoalba
7    pygmy killer whale               817    20.50         Feresa attenuata
8    false killer whale               150     2.80         Pseudorca crassidens
9    melon-headed whale              2950     3.00         Peponocephala electra
10    short-finned pilot whale        8850     3.70         Globicephala macrorhynchus
11    sperm whale                     7082    17.30         Physeter macrocephalus
12    dwarf sperm whale              19000     3.00         Kogia sima
13    pygmy sperm whale                 50     3.50         Kogia breviceps
14    orca                              50    10.70         Orcinus orca
15    Blainville’s beaked whale       2200     5.00         Mesoplodon densirostris
16    Cuvier’s beaked Whale          13000     8.30         Ziphius cavirostris
17    pantropical spotted dolphin  3000000     2.50         Stenella attenuata
Display MarineMammalsOfHawaii array[] sorted by name:
index  name                       population  length (feet)  Genus species
0    Blainville’s beaked whale       2200     5.00         Mesoplodon densirostris
1    Cuvier’s beaked Whale          13000     8.30         Ziphius cavirostris
2    Hawaiian monk seal              1100     2.40         Monachus schauinslandi
3    Risso’s dolphin                85000     4.00         Grampus griseus
4    common bottlenose dolphin        235     3.50         Tursiops truncatus
5    dwarf sperm whale              19000     3.00         Kogia sima
6    false killer whale               150     2.80         Pseudorca crassidens
7    humpback whale                 10000    16.00         Megaptera novaeangliae
8    melon-headed whale              2950     3.00         Peponocephala electra
9    orca                              50    10.70         Orcinus orca
10    pantropical spotted dolphin  3000000     2.50         Stenella attenuata
11    pygmy killer whale               817    20.50         Feresa attenuata
12    pygmy sperm whale                 50     3.50         Kogia breviceps
13    rough-toothed dolphin         150000     2.83         Steno bredanensis
14    short-finned pilot whale        8850     3.70         Globicephala macrorhynchus
15    sperm whale                     7082    17.30         Physeter macrocephalus
16    spinner dolphin                 3351     2.35         Stenella longirostris
17    striped dolphin              2000000     2.60         Stenella coeruleoalba