diff --git a/TravelBuddyApp/.classpath b/TravelBuddyApp/.classpath index d2a08eb..373e075 100644 --- a/TravelBuddyApp/.classpath +++ b/TravelBuddyApp/.classpath @@ -36,5 +36,6 @@ + diff --git a/TravelBuddyApp/dependency-reduced-pom.xml b/TravelBuddyApp/dependency-reduced-pom.xml index 75cd7d4..67b2bb9 100644 --- a/TravelBuddyApp/dependency-reduced-pom.xml +++ b/TravelBuddyApp/dependency-reduced-pom.xml @@ -80,17 +80,25 @@ - org.junit.jupiter - junit-jupiter-api - 5.8.1 + junit + junit + 4.13.1 test - opentest4j - org.opentest4j + hamcrest-core + org.hamcrest + + + + org.junit.jupiter + junit-jupiter-engine + 5.9.3 + test + - junit-platform-commons + junit-platform-engine org.junit.platform @@ -101,13 +109,13 @@ org.junit.jupiter - junit-jupiter-engine - 5.8.1 + junit-jupiter-api + 5.9.3 test - junit-platform-engine - org.junit.platform + opentest4j + org.opentest4j apiguardian-api @@ -115,6 +123,18 @@ + + org.junit.platform + junit-platform-commons + 1.9.3 + test + + + apiguardian-api + org.apiguardian + + + 21 diff --git a/TravelBuddyApp/src/main/java/domain/KurztripEmpfehlung.java b/TravelBuddyApp/src/main/java/domain/KurztripEmpfehlung.java index a741bb7..9c2ce76 100644 --- a/TravelBuddyApp/src/main/java/domain/KurztripEmpfehlung.java +++ b/TravelBuddyApp/src/main/java/domain/KurztripEmpfehlung.java @@ -109,9 +109,6 @@ public class KurztripEmpfehlung { - - - private List ladeAlleOrte() { List alleOrte = new ArrayList<>(); diff --git a/TravelBuddyApp/src/main/java/domain/Ort.java b/TravelBuddyApp/src/main/java/domain/Ort.java index 75b13a1..a6ba049 100644 --- a/TravelBuddyApp/src/main/java/domain/Ort.java +++ b/TravelBuddyApp/src/main/java/domain/Ort.java @@ -4,38 +4,46 @@ import java.io.IOException; public class Ort { - private String plz; - private String OrtName; + private int plz; + private String ortName; + private double breitengrad; + private double längengrad; - public Ort(String plz, String name) { + + public Ort(int plz, String name) { this.plz = plz; - this.OrtName = name; + this.ortName = name; } - public String getPLZ() { + + public Ort(int plz, String name, double breitengrad, double längengrad) { + this.plz = plz; + this.ortName = name; + this.breitengrad = breitengrad; + this.längengrad = längengrad; + } + + public int getPLZ() { return plz; } - public void setPLZ(String plz) { - this.plz = plz; - } - public String getOrtName() { - return OrtName; + return ortName; } - public void setName(String name) { - this.OrtName = name; + + + public double getBreitengrad() { + return breitengrad; } - @Override - public String toString() { - return OrtName + " (" + plz + ")"; + public double getLängengrad() { + return längengrad; } public String getAktuellesWetter() { try { - return WetterService.getAktuellesWetter(OrtName); + return WetterService.getAktuellesWetter(ortName); } catch (IOException | InterruptedException e) { e.printStackTrace(); return "Fehler beim Abrufen des aktuellen Wetters"; @@ -44,7 +52,7 @@ public class Ort { public String getWettervorhersage() { try { - return WetterService.getWettervorhersage(OrtName); + return WetterService.getWettervorhersage(ortName); } catch (IOException | InterruptedException e) { e.printStackTrace(); return "Fehler beim Abrufen der Wettervorhersage"; diff --git a/TravelBuddyApp/src/main/java/domain/User.java b/TravelBuddyApp/src/main/java/domain/User.java index fc3daef..b999eff 100644 --- a/TravelBuddyApp/src/main/java/domain/User.java +++ b/TravelBuddyApp/src/main/java/domain/User.java @@ -92,24 +92,25 @@ public class User { } public boolean einloggen() { - - try (BufferedReader reader = new BufferedReader(new FileReader("users.txt"))) { - String line; - while ((line = reader.readLine()) != null) { - String[] parts = line.split(","); - if (parts[0].equals(username) && parts[1].equals(hashedPassword)) { - this.heimatstandort = new Ort(parts[2], parts[3]); - this.auto = new Auto(parts[4], Double.parseDouble(parts[5])); - this.durchschnittsgeschwindigkeitPKW = Double.parseDouble(parts[6]); - this.durchschnittsgeschwindigkeitFahrrad = Double.parseDouble(parts[7]); - return true; - } - } - } catch (IOException e) { - e.printStackTrace(); - } - return false; + try (BufferedReader reader = new BufferedReader(new FileReader("users.txt"))) { + String line; + while ((line = reader.readLine()) != null) { + String[] parts = line.split(","); + if (parts[0].equals(username) && parts[1].equals(hashedPassword)) { + int plz = Integer.parseInt(parts[2]); + this.heimatstandort = new Ort(plz, parts[3]); + this.auto = new Auto(parts[4], Double.parseDouble(parts[5])); + this.durchschnittsgeschwindigkeitPKW = Double.parseDouble(parts[6]); + this.durchschnittsgeschwindigkeitFahrrad = Double.parseDouble(parts[7]); + return true; + } + } + } catch (IOException e) { + e.printStackTrace(); + } + return false; } + public String zeigeWetterHeimatstandort() { try { diff --git a/TravelBuddyApp/src/main/java/fassade/ReiseFassade.java b/TravelBuddyApp/src/main/java/fassade/ReiseFassade.java index 6850cdb..12877de 100644 --- a/TravelBuddyApp/src/main/java/fassade/ReiseFassade.java +++ b/TravelBuddyApp/src/main/java/fassade/ReiseFassade.java @@ -34,6 +34,7 @@ public class ReiseFassade { kurztripEmpfehlung.setHeimatort(user.getHeimatstandort()); } + public double berechneEntfernung() { return reiseplanung.getEntfernung(); diff --git a/TravelBuddyApp/src/main/java/fassade/UserFassade.java b/TravelBuddyApp/src/main/java/fassade/UserFassade.java index a7f5058..043d48f 100644 --- a/TravelBuddyApp/src/main/java/fassade/UserFassade.java +++ b/TravelBuddyApp/src/main/java/fassade/UserFassade.java @@ -6,7 +6,7 @@ import domain.Auto; public class UserFassade { - public User registrieren(String username, String password, String plz, String ortName, String autoName, + public User registrieren(String username, String password, int plz, String ortName, String autoName, double co2AusstossProKm, double durchschnittsgeschwindigkeitPKW, double durchschnittsgeschwindigkeitFahrrad) { Ort heimatstandort = new Ort(plz, ortName); diff --git a/TravelBuddyApp/src/main/java/ui/UserInterface.java b/TravelBuddyApp/src/main/java/ui/UserInterface.java index 768b759..cedd9b3 100644 --- a/TravelBuddyApp/src/main/java/ui/UserInterface.java +++ b/TravelBuddyApp/src/main/java/ui/UserInterface.java @@ -175,7 +175,7 @@ public class UserInterface { switch (transportmittel) { case "fahrrad": - List fahrradOrte = reiseFacade.zufallsorteFahrrad(100); + List fahrradOrte = reiseFacade.zufallsorteFahrrad(10000); if (fahrradOrte.isEmpty()) { System.out.println("Keine Orte innerhalb von 100 km gefunden."); } else { @@ -205,6 +205,8 @@ public class UserInterface { } } + + public static void main(String[] args) { new UserInterface(); diff --git a/TravelBuddyApp/src/test/java/UserTest.java b/TravelBuddyApp/src/test/java/UserTest.java deleted file mode 100644 index 644f0fb..0000000 --- a/TravelBuddyApp/src/test/java/UserTest.java +++ /dev/null @@ -1,4 +0,0 @@ - -public class UserTest { - -} diff --git a/TravelBuddyApp/users.txt b/TravelBuddyApp/users.txt index e69de29..4d31b76 100644 --- a/TravelBuddyApp/users.txt +++ b/TravelBuddyApp/users.txt @@ -0,0 +1,3 @@ +dana,a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3,67105,Schifferstadt,audi,123.0,60.0,30.0 +max,a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3,555,berlin,audi,12.0,23.0,34.0 +tina,a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3,1328,Dresden,audi,12.0,34.0,56.0