限制题目数量

fanxuerun_branch
fanxuerun 7 months ago
parent 824a8e3a3d
commit fc131d7b29

@ -6,10 +6,14 @@ import java.util.*;
public class QuestionService {
/*生成试卷的题目部分*/
public List<Question> generateQuestions(String difficulty, int count) {
if(count < 10 || count > 30) {
return null;
}
List<Question> questions = new ArrayList<>();
Set<String> usedQuestions = new HashSet<>();
QuestionGenerator generator = QuestionGeneratorFactory.getGenerator(difficulty);
while (questions.size() < count) {
Question q = generator.generateQuestion();
if (usedQuestions.add(q.getContent())) {

Loading…
Cancel
Save