📄 abstractquestion.java
字号:
package paper;
import java.io.Serializable;
/**
* @author SpiritRain
*
* Abstract class of Question
*
*/
public abstract class AbstractQuestion implements Serializable {
/**
* to identify Binary Question
*/
public static final int BINARY = 1;
/**
* to identify Choice Question
*/
public static final int CHOICE = 2;
/**
* to identify factual Question
*/
public static final int FACTUAL = 0;
/**
* Store Question Name
*/
public static final String[] TYPENAME =
{ "Factual Question", "Binary Question", "Choice Question" };
/**
* create a new empty question with specifically type
* @param type Question type
* @return Question
*/
public static AbstractQuestion createNewQuestion(int type) {
if (type == FACTUAL) {
return new FactualQuestion("", null, "", 0, 0);
} else if (type == BINARY) {
return new BinaryQuestion("", null, "", 0, 0);
} else if (type == CHOICE) {
return new ChoiceQuestion("", null, "", 0, 0);
} else {
return null;
}
}
/**
* answers of the question
*/
protected AbstractAnswerSet answers;
/**
* difficulty value
*/
protected int diff;
/**
* hints String
*/
protected String hint;
/**
* Strings to describe the question
*/
protected String questionText;
/**
* score value
*/
protected int score;
/**
* Create a question and initiate variables
* @param qutestionText question string to discribe the question
* @param answers answer of the question
* @param hint hint of the question
* @param score score of the question
* @param diff difficulty of the question
*/
public AbstractQuestion(
String qutestionText,
AbstractAnswerSet answers,
String hint,
int score,
int diff) {
this.questionText = qutestionText;
this.answers = answers;
this.hint = hint;
this.score = score;
this.diff = diff;
}
/**
* if ans is correct, return score
* else return 0
* @param ans the answer to be checked
*/
public int check(AbstractAnswer ans) {
if (answers.check(ans)) {
return score;
} else {
return 0;
}
}
/**
* return the score of the question
* @return score value
*/
public int getQuestionScore() {
return score;
}
/**
* return the difficulty of the question
* @return difficulty value
*/
public int getDifficulty() {
return diff;
}
/**
* get hint of the question
* @return string of hint
*/
public String getHint() {
return hint;
}
/**
* get key answer of the question
* @return key answer
*/
public AbstractAnswer getKey() {
return answers.getKey();
}
/**
* return question text of the question
* @return string of question text
*/
public String getQuestionText() {
return questionText;
}
/**
* return the type of current question
* @return type value
*/
public abstract int getType();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -