You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pairedProject/src/main/java/com/ybw/mathapp/entity/QuestionWithOptions.java

57 lines
1.5 KiB

package com.ybw.mathapp.entity;
import java.util.List;
/**
* 选择题对象,包含题干、选项和正确答案索引。
*
* @author 你的名字
* @since 2025
*/
public class QuestionWithOptions {
private String questionText; // 题干
private List<String> options; // 选项列表
private int correctAnswerIndex; // 正确答案的索引 (0-based)
public QuestionWithOptions(String questionText, List<String> options, int correctAnswerIndex) {
this.questionText = questionText;
this.options = options;
this.correctAnswerIndex = correctAnswerIndex;
}
public String getQuestionText() {
return questionText;
}
public void setQuestionText(String questionText) {
this.questionText = questionText;
}
public List<String> getOptions() {
return options;
}
public void setOptions(List<String> options) {
this.options = options;
}
public int getCorrectAnswerIndex() {
return correctAnswerIndex;
}
public void setCorrectAnswerIndex(int correctAnswerIndex) {
this.correctAnswerIndex = correctAnswerIndex;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Question: ").append(questionText).append("\n");
for (int i = 0; i < options.size(); i++) {
sb.append("Option ").append((char)('A' + i)).append(": ").append(options.get(i)).append("\n");
}
sb.append("Correct Answer: ").append((char)('A' + correctAnswerIndex));
return sb.toString();
}
}