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.
27 lines
616 B
27 lines
616 B
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* 题目仓库类,负责管理已生成的题目,避免重复。
|
|
*/
|
|
public class QuestionRepository {
|
|
private Set<String> generatedQuestions = new HashSet<>();
|
|
|
|
/**
|
|
* 检查题目是否重复
|
|
* @param question 题目
|
|
* @return 是否重复
|
|
*/
|
|
public boolean isDuplicate(String question) {
|
|
return generatedQuestions.contains(question);
|
|
}
|
|
|
|
/**
|
|
* 将题目添加到仓库
|
|
* @param question 题目
|
|
*/
|
|
public void addQuestion(String question) {
|
|
generatedQuestions.add(question);
|
|
}
|
|
}
|