Browse Source

Update QuizCommand.java

Getting userinput and checking whether answer is correct
remotes/origin/quiz
Friederike von Gruben 2 years ago
parent
commit
50784178b3
  1. 10
      src/main/java/org/bitbiome/commands/QuizCommand.java

10
src/main/java/org/bitbiome/commands/QuizCommand.java

@ -30,7 +30,17 @@ public class QuizCommand implements CommandAPI {
String antwort = antworten.getString(i);
System.out.println(i + 1 + ". " + antwort);
}
Scanner quizScanner = new Scanner(System.in);
int eingabe = quizScanner.nextInt();
String korrekteAntwort = frage.getString("korrekteAntwort");
if (antworten.getString(eingabe - 1).equalsIgnoreCase(korrekteAntwort)) {
System.out.println("Richtige Antwort!\n");
} else {
System.out.println("Leider falsch... Richtig ist: " + korrekteAntwort + "\n");
}
System.out.println("Das Quiz ist vorbei.");
}
}

Loading…
Cancel
Save