From 44b385bf3d6b155c36b21a8948de280bd38210c5 Mon Sep 17 00:00:00 2001 From: Selim Eser <2211482@stud.hs-mannheim.de> Date: Sun, 9 Jun 2024 18:38:38 +0200 Subject: [PATCH] random_destinations_car method implemented --- .../java/de/hs_mannheim/domain/System.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hs_mannheim/domain/System.java b/src/main/java/de/hs_mannheim/domain/System.java index aace573..02847ab 100644 --- a/src/main/java/de/hs_mannheim/domain/System.java +++ b/src/main/java/de/hs_mannheim/domain/System.java @@ -12,6 +12,7 @@ import java.net.http.HttpResponse.BodyHandlers; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.TreeSet; import org.json.JSONObject; @@ -71,7 +72,24 @@ public class System { } public ArrayList random_destinations_car(){ - return new ArrayList(); + + ArrayList result = new ArrayList<>(); + + InputStream inputStream = Main.class.getResourceAsStream("/zip.csv"); + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { + String line; + while ((line = reader.readLine()) != null) { + + line = line.replace("\"", ""); + + if(Double.parseDouble(distance(line.split(";")[0]).replace(" km", "")) > 150) + result.add(line); + + } + } catch (Exception e) {} + + return result; } public ArrayList random_destinations_bike(){