Zwischenstand

dev
danai 2024-06-17 13:09:35 +02:00
parent 1746ad7bb1
commit 91dcafc607
10 changed files with 82 additions and 53 deletions

View File

@ -36,5 +36,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -80,17 +80,25 @@
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.1</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>opentest4j</artifactId>
<groupId>org.opentest4j</groupId>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-platform-commons</artifactId>
<artifactId>junit-platform-engine</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
<exclusion>
@ -101,13 +109,13 @@
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-platform-engine</artifactId>
<groupId>org.junit.platform</groupId>
<artifactId>opentest4j</artifactId>
<groupId>org.opentest4j</groupId>
</exclusion>
<exclusion>
<artifactId>apiguardian-api</artifactId>
@ -115,6 +123,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>1.9.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>apiguardian-api</artifactId>
<groupId>org.apiguardian</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>21</maven.compiler.target>

View File

@ -109,9 +109,6 @@ public class KurztripEmpfehlung {
private List<Ort> ladeAlleOrte() {
List<Ort> alleOrte = new ArrayList<>();

View File

@ -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";

View File

@ -92,25 +92,26 @@ 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 {
return WetterService.getAktuellesWetter(heimatstandort.getOrtName());

View File

@ -35,6 +35,7 @@ public class ReiseFassade {
}
public double berechneEntfernung() {
return reiseplanung.getEntfernung();
}

View File

@ -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);

View File

@ -175,7 +175,7 @@ public class UserInterface {
switch (transportmittel) {
case "fahrrad":
List<Ort> fahrradOrte = reiseFacade.zufallsorteFahrrad(100);
List<Ort> 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();

View File

@ -1,4 +0,0 @@
public class UserTest {
}

View File

@ -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