eac5c9561839d29a74ce91efd0768c24b236616a
2 import java
.io
.FileNotFoundException
;
3 import java
.util
.ArrayList
;
5 import java
.util
.Scanner
;
9 private String csvFile
= "data/countries.csv";
10 private String
[] continents
= {"Africa", "Americas", "Asia", "Europe", "Oceania"};
11 private ArrayList
<Country
> countryArrayListEurope
= new ArrayList
<>();
12 private ArrayList
<Country
> countryArrayListAfrica
= new ArrayList
<>();
13 private ArrayList
<Country
> countryArrayListAmericas
= new ArrayList
<>();
14 private ArrayList
<Country
> countryArrayListAsia
= new ArrayList
<>();
15 private ArrayList
<Country
> countryArrayListOceania
= new ArrayList
<>();
19 this.loadCSVCountries();
22 public String
[] getContinents() {
26 public ArrayList
<Country
> getCountryArrayListAfrica() {
27 return countryArrayListAfrica
;
30 public ArrayList
<Country
> getCountryArrayListAsia() {
31 return countryArrayListAsia
;
34 public ArrayList
<Country
> getCountryArrayListAmericas() {
35 return countryArrayListAmericas
;
38 public ArrayList
<Country
> getCountryArrayListEurope() {
39 return countryArrayListEurope
;
42 public ArrayList
<Country
> getCountryArrayListOceania() {
43 return countryArrayListOceania
;
46 public void loadCSVCountries() {
47 CSVUtils csvUtils
= new CSVUtils();
48 Scanner scanner
= null;
50 scanner
= new Scanner(new File(csvFile
));
51 } catch (FileNotFoundException e
) {
54 while (scanner
.hasNext()) {
56 List
<String
> line
= csvUtils
.parseLine(scanner
.nextLine());
58 String c3
= line
.get(0);
59 String
[] splitArray
= c3
.split(",");
60 String c2
= line
.get(16);
61 String
[] splitArray2
= c2
.split(",");
63 if (line
.get(12).equals("Europe")) {
64 Country c
= new Country(splitArray
[1], line
.get(12), Double
.parseDouble(splitArray2
[0]), Double
.parseDouble(splitArray2
[1]));
65 countryArrayListEurope
.add(c
);
66 } else if (line
.get(12).equals("Africa")) {
67 Country c
= new Country(splitArray
[1], line
.get(12), Double
.parseDouble(splitArray2
[0]), Double
.parseDouble(splitArray2
[1]));
68 countryArrayListAfrica
.add(c
);
69 } else if (line
.get(12).equals("Americas")) {
70 Country c
= new Country(splitArray
[1], line
.get(12), Double
.parseDouble(splitArray2
[0]), Double
.parseDouble(splitArray2
[1]));
71 countryArrayListAmericas
.add(c
);
72 } else if (line
.get(12).equals("Asia")) {
73 Country c
= new Country(splitArray
[1], line
.get(12), Double
.parseDouble(splitArray2
[0]), Double
.parseDouble(splitArray2
[1]));
74 countryArrayListAsia
.add(c
);
75 } else if (line
.get(12).equals("Oceania")) {
76 Country c
= new Country(splitArray
[1], line
.get(12), Double
.parseDouble(splitArray2
[0]), Double
.parseDouble(splitArray2
[1]));
77 countryArrayListOceania
.add(c
);
83 /*Utils.displayArrayList(countryArrayListOceania);
84 Utils.displayArrayList(countryArrayListAfrica);
85 Utils.displayArrayList(countryArrayListAmericas);
86 Utils.displayArrayList(countryArrayListAsia);
87 Utils.displayArrayList(countryArrayListEurope);*/