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.
39 lines
1.3 KiB
39 lines
1.3 KiB
package com.mathlearning.model;
|
|
|
|
import java.io.Serializable;
|
|
|
|
public class Question implements Serializable {
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
private String content;
|
|
private String[] options;
|
|
private String correctAnswer;
|
|
private String userAnswer;
|
|
|
|
public Question(String content, String options, String correctAnswer) {
|
|
this.content = content;
|
|
this.options = options.split(",");
|
|
this.correctAnswer = correctAnswer;
|
|
}
|
|
|
|
// Getters and setters
|
|
public String getContent() { return content; }
|
|
public void setContent(String content) { this.content = content; }
|
|
|
|
public String[] getOptions() { return options; }
|
|
public void setOptions(String[] options) { this.options = options; }
|
|
|
|
public String getCorrectAnswer() { return correctAnswer; }
|
|
public void setCorrectAnswer(String correctAnswer) { this.correctAnswer = correctAnswer; }
|
|
|
|
public String getUserAnswer() { return userAnswer; }
|
|
public void setUserAnswer(String userAnswer) { this.userAnswer = userAnswer; }
|
|
|
|
public boolean isCorrect() {
|
|
return correctAnswer != null && correctAnswer.equals(userAnswer);
|
|
}
|
|
|
|
public String getOptionsAsString() {
|
|
return String.join(",", options);
|
|
}
|
|
} |