From: Sylvain Papa Date: Fri, 18 Jan 2019 10:32:01 +0000 (+0100) Subject: Country+Region add flag X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f710e396068ce8fb27e753a3e1be0b36430275b1;p=Persons_Comparator.git Country+Region add flag --- diff --git a/src/Country.java b/src/Country.java index cb67273..2516c2b 100644 --- a/src/Country.java +++ b/src/Country.java @@ -1,17 +1,16 @@ -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) { @@ -42,6 +41,14 @@ public class Country { 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; @@ -64,6 +71,7 @@ public class Country { ", region='" + region + '\'' + ", lat=" + lat + ", lng=" + lng + + ", flag=" + flag + '}'; } } diff --git a/src/Region.java b/src/Region.java index 7c50c89..c97b5ff 100644 --- a/src/Region.java +++ b/src/Region.java @@ -55,19 +55,19 @@ public class Region { 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); } }