2023-10-10 17:44:25 +02:00
|
|
|
import Facade.Spiel;
|
|
|
|
import Infrastructure.Persistenz;
|
|
|
|
import UI.SpielCLI;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
public class Main {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
String name = "Wizard";
|
|
|
|
Spiel spiel = null;
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
new SpielCLI(spiel);
|
|
|
|
|
|
|
|
try {
|
|
|
|
Persistenz.speichereDaten(name, spiel);
|
|
|
|
} catch (IOException e) {
|
|
|
|
System.out.println("Konnte Daten nicht speicher!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|