From 9deda6bf76e888017129004dc13e5217f8ca9d40 Mon Sep 17 00:00:00 2001 From: Selim Eser <2211482@stud.hs-mannheim.de> Date: Sun, 9 Jun 2024 18:39:48 +0200 Subject: [PATCH] random_destinations_bike method implemented --- .../java/de/hs_mannheim/domain/System.java | 18 +++++++++++++++++- 1 file changed, 17 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 02847ab..28a32be 100644 --- a/src/main/java/de/hs_mannheim/domain/System.java +++ b/src/main/java/de/hs_mannheim/domain/System.java @@ -93,7 +93,23 @@ public class System { } public ArrayList random_destinations_bike(){ - 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", "")) < 100) + result.add(line); + + } + } catch (Exception e) {} + + return result; } public String[] destination_details(String destination_zip){