TUI package
parent
ad88776a5a
commit
93a7156374
|
@ -0,0 +1,74 @@
|
|||
package TUI;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import fassade.KniffelSpiel;
|
||||
|
||||
public class KniffelSpielTUI {
|
||||
|
||||
private KniffelSpiel facade;
|
||||
private Scanner scanner;
|
||||
|
||||
public KniffelSpielTUI() {
|
||||
facade = new KniffelSpiel();
|
||||
scanner = new Scanner(System.in);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void startUI() {
|
||||
boolean running = true;
|
||||
|
||||
while (running) {
|
||||
System.out.println("1. Start Game");
|
||||
System.out.println("2. Highscores anzeigen");
|
||||
System.out.println("3. Highscores löschen");
|
||||
System.out.println("4. Spiel beenden");
|
||||
System.out.print("Wählen Sie eine Option: ");
|
||||
int choice = scanner.nextInt();
|
||||
switch (choice) {
|
||||
case 1:
|
||||
facade.startGame();
|
||||
break;
|
||||
case 2:
|
||||
List<String> highscores = facade.getHighscores();
|
||||
if (highscores.isEmpty()) {
|
||||
System.out.println("Es gibt keine Highscores.");
|
||||
System.out.println("---------------------------------");
|
||||
} else {
|
||||
System.out.println("Highscores:");
|
||||
for (String score : highscores) {
|
||||
System.out.println(score);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
System.out.println("Sind Sie sicher, dass Sie die Highscores löschen möchten? (ja/nein)");
|
||||
String confirmation = scanner.next();
|
||||
if (confirmation.equalsIgnoreCase("ja")) {
|
||||
facade.deleteHighscores();
|
||||
System.out.println("Highscores wurden gelöscht.");
|
||||
} else {
|
||||
System.out.println("Löschen der Highscores abgebrochen.");
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
running = false;
|
||||
System.out.println("Ende des Spiels!");
|
||||
break;
|
||||
default:
|
||||
System.out.println("Ungültige Auswahl, bitte versuchen Sie es erneut.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
KniffelSpielTUI ui = new KniffelSpielTUI();
|
||||
ui.startUI();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue