- 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 Rissos 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 Blainvilles beaked whale 2200 5.00 Mesoplodon densirostris
16 Cuviers 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 Blainvilles beaked whale 2200 5.00 Mesoplodon densirostris
1 Cuviers beaked Whale 13000 8.30 Ziphius cavirostris
2 Hawaiian monk seal 1100 2.40 Monachus schauinslandi
3 Rissos 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
Reviews
There are no reviews yet.