-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathQuizQuestion.java
More file actions
34 lines (29 loc) · 965 Bytes
/
QuizQuestion.java
File metadata and controls
34 lines (29 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.togetherjava.tjplays.trivia;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* Represents a single quiz question for Java trivia.
* Used by TriviaManager and JavaQuizCommand to display questions and validate answers.
* Future contributors can use this for any quiz/trivia feature needing a question, choices, and answer index.
*/
public record QuizQuestion(
@JsonProperty("question") String question,
@JsonProperty("choices") List<String> choices,
@JsonProperty("correct") int correctAnswerIndex
) {
@JsonCreator
public QuizQuestion {}
public String getQuestion() {
return question;
}
public List<String> getChoices() {
return choices;
}
/**
* Returns the index of the correct answer in the choices list.
*/
public int getCorrectAnswerIndex() {
return correctAnswerIndex;
}
}