-import javax.swing.*;
-
public class Country {
private String name;
private String region;
private double lat;
private double lng;
- private ImageIcon flag;
+ private String flag;
- public Country(String name, String region, double lat, double lng) {
+ public Country(String name, String region, double lat, double lng, String flag) {
setName(name);
setRegion(region);
setLat(lat);
setLng(lng);
+ setFlag(flag);
}
public void setName(String name) {
return lng;
}
+ public void setFlag(String flag) {
+ this.flag = flag;
+ }
+
+ public String getFlag() {
+ return flag;
+ }
+
public int distanceTo(Country country) {
if ((this.lat == country.lat) && (this.lng == country.lng)) {
return 0;
", region='" + region + '\'' +
", lat=" + lat +
", lng=" + lng +
+ ", flag=" + flag +
'}';
}
}
String latLng = line.get(16);
String[] latLngArray = latLng.split(",");
if (line.get(12).equals("Europe")) {
- Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]));
+ Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]), line.get(21));
countryArrayListEurope.add(c);
} else if (line.get(12).equals("Africa")) {
- Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]));
+ Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]), line.get(21));
countryArrayListAfrica.add(c);
} else if (line.get(12).equals("Americas")) {
- Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]));
+ Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]), line.get(21));
countryArrayListAmericas.add(c);
} else if (line.get(12).equals("Asia")) {
- Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]));
+ Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]), line.get(21));
countryArrayListAsia.add(c);
} else if (line.get(12).equals("Oceania")) {
- Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]));
+ Country c = new Country(countryArray[1], line.get(12), Double.parseDouble(latLngArray[0]), Double.parseDouble(latLngArray[1]), line.get(21));
countryArrayListOceania.add(c);
}
}