2023-10-10 17:44:25 +02:00
|
|
|
import Facade.Spiel;
|
|
|
|
import Infrastructure.Persistenz;
|
|
|
|
import UI.SpielCLI;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2023-11-07 15:48:15 +01:00
|
|
|
import Domain.Exceptions.SpielNotFoundException;
|
|
|
|
|
2023-10-10 17:44:25 +02:00
|
|
|
public class Main {
|
2023-11-07 15:48:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws SpielNotFoundException {
|
2023-10-10 17:44:25 +02:00
|
|
|
String name = "Wizard";
|
|
|
|
Spiel spiel = null;
|
2023-11-07 15:48:15 +01:00
|
|
|
|
2023-10-10 17:44:25 +02:00
|
|
|
|
2023-10-10 17:54:22 +02:00
|
|
|
if (Persistenz.sindDatenVorhanden(name)) {
|
|
|
|
try {
|
2023-10-10 17:44:25 +02:00
|
|
|
System.out.println("Lade daten");
|
|
|
|
spiel = (Spiel) Persistenz.ladeDaten(name);
|
2023-10-11 13:59:46 +02:00
|
|
|
System.out.println("laden erfolgreich");
|
2023-10-10 17:54:22 +02:00
|
|
|
} catch (IOException e) {
|
2023-10-10 17:44:25 +02:00
|
|
|
System.out.println("Konnte file nicht laden.");
|
|
|
|
System.out.println(e.getLocalizedMessage());
|
|
|
|
|
2023-10-10 17:54:22 +02:00
|
|
|
} catch (ClassNotFoundException cnfe) {
|
2023-10-10 17:44:25 +02:00
|
|
|
System.out.println("Konnte file nicht laden.");
|
|
|
|
System.out.println(cnfe.getLocalizedMessage());
|
2023-10-10 17:54:22 +02:00
|
|
|
} finally {
|
|
|
|
if (spiel == null) {
|
2023-10-10 17:44:25 +02:00
|
|
|
System.out.println("Initialisiere neues Spiel");
|
|
|
|
spiel = new Spiel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-10 17:54:22 +02:00
|
|
|
} else {
|
2023-10-10 17:44:25 +02:00
|
|
|
spiel = new Spiel();
|
2023-11-07 15:48:15 +01:00
|
|
|
|
2023-10-10 17:44:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
new SpielCLI(spiel);
|
|
|
|
|
|
|
|
try {
|
|
|
|
Persistenz.speichereDaten(name, spiel);
|
|
|
|
} catch (IOException e) {
|
|
|
|
System.out.println("Konnte Daten nicht speicher!");
|
|
|
|
}
|
2023-11-07 15:48:15 +01:00
|
|
|
|
2023-10-10 17:44:25 +02:00
|
|
|
}
|
2023-11-07 15:48:15 +01:00
|
|
|
|
|
|
|
|
2023-10-10 17:44:25 +02:00
|
|
|
}
|