|
|
|
|
@ -9,10 +9,12 @@ public class MultipleChoiceGenerator {
|
|
|
|
|
String[] QuestionList ;
|
|
|
|
|
String[] AnswerList ;
|
|
|
|
|
String[] ChoiceList ;
|
|
|
|
|
String[] CorrectAnswerNo;
|
|
|
|
|
|
|
|
|
|
MultipleChoiceGenerator(int count, User nowUser){// 如此声明MultipleChoiceGenerator实例,再调用下面三个接口
|
|
|
|
|
public MultipleChoiceGenerator(int count, User nowUser){// 如此声明MultipleChoiceGenerator实例,再调用下面三个接口
|
|
|
|
|
this.QuestionList = new String[count];
|
|
|
|
|
this.ChoiceList = new String[count];
|
|
|
|
|
this.CorrectAnswerNo = new String[count];
|
|
|
|
|
this.QuestionList = SetQuestionList(count, nowUser);
|
|
|
|
|
SetChoiceList();
|
|
|
|
|
}
|
|
|
|
|
@ -29,10 +31,14 @@ public class MultipleChoiceGenerator {
|
|
|
|
|
return this.AnswerList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String[] GetCorrectAnswerNo(){
|
|
|
|
|
return this.CorrectAnswerNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetChoiceList(){
|
|
|
|
|
for(int i = 0 ; i < this.AnswerList.length ; i++){
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
String[] choiceNo = {"A.","B.","C.","D."};
|
|
|
|
|
String[] choiceNo = {"A","B","C","D"};
|
|
|
|
|
String[] choices = new String[4];
|
|
|
|
|
double correctChoice = Double.parseDouble(this.AnswerList[i]);
|
|
|
|
|
int position = random.nextInt(4);
|
|
|
|
|
@ -44,11 +50,14 @@ public class MultipleChoiceGenerator {
|
|
|
|
|
double choice = correctChoice;
|
|
|
|
|
double offset = random.nextInt(41) - 20;
|
|
|
|
|
choice += offset;
|
|
|
|
|
choices[j] =choiceNo[j] + String.format("%.2f", choice);
|
|
|
|
|
choices[j] =choiceNo[j] +"." + String.format("%.2f", choice);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
CorrectAnswerNo[i] = choiceNo[j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ChoiceList[i] = String.join("\n", choices);
|
|
|
|
|
this.ChoiceList[i] = String.join(" ", choices);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|