Corrected the method logic
parent
5a6fe3fc53
commit
1aed134131
|
@ -82,42 +82,52 @@ public class System {
|
||||||
|
|
||||||
public ArrayList<String> random_destinations_car(){
|
public ArrayList<String> random_destinations_car(){
|
||||||
|
|
||||||
ArrayList<String> result = new ArrayList<>();
|
ArrayList<String> mem = new ArrayList<>();
|
||||||
|
|
||||||
InputStream inputStream = Main.class.getResourceAsStream("/zip.csv");
|
InputStream inputStream = Main.class.getResourceAsStream("/zip.csv");
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null && result.size()<3) {
|
while ((line = reader.readLine()) != null) {
|
||||||
|
|
||||||
line = line.replace("\"", "");
|
line = line.replace("\"", "");
|
||||||
|
|
||||||
if(Double.parseDouble(distance(line.split(";")[0]).replace(" km", "")) > 150)
|
if(Double.parseDouble(distance(line.split(";")[0]).replace(" km", "")) > 150)
|
||||||
result.add(line);
|
mem.add(line);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
|
|
||||||
|
ArrayList<String> result = new ArrayList<>();
|
||||||
|
|
||||||
|
for(int i = 0; i<3; i++)
|
||||||
|
result.add(mem.get((int) (Math.random()*mem.size())));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> random_destinations_bike(){
|
public ArrayList<String> random_destinations_bike(){
|
||||||
ArrayList<String> result = new ArrayList<>();
|
ArrayList<String> mem = new ArrayList<>();
|
||||||
|
|
||||||
InputStream inputStream = Main.class.getResourceAsStream("/zip.csv");
|
InputStream inputStream = Main.class.getResourceAsStream("/zip.csv");
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null && result.size()<3) {
|
while ((line = reader.readLine()) != null) {
|
||||||
|
|
||||||
line = line.replace("\"", "");
|
line = line.replace("\"", "");
|
||||||
|
|
||||||
if(Double.parseDouble(distance(line.split(";")[0]).replace(" km", "")) < 100)
|
if(Double.parseDouble(distance(line.split(";")[0]).replace(" km", "")) < 100)
|
||||||
result.add(line);
|
mem.add(line);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
|
|
||||||
|
ArrayList<String> result = new ArrayList<>();
|
||||||
|
|
||||||
|
for(int i = 0; i<3; i++)
|
||||||
|
result.add(mem.get((int) (Math.random()*mem.size())));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue