|
|
|
@ -27,7 +27,7 @@ import java.util.Set;
|
|
|
|
|
*/
|
|
|
|
|
public class MathExamGenerator {
|
|
|
|
|
// 预设的用户账号信息
|
|
|
|
|
private static final Map<String, UserInfo> USER_ACCOUNTS = new HashMap<>();
|
|
|
|
|
private static final Map<String, UserInfo> userAccounts = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// 当前登录用户信息
|
|
|
|
|
private static UserInfo currentUser = null;
|
|
|
|
@ -39,19 +39,19 @@ public class MathExamGenerator {
|
|
|
|
|
static {
|
|
|
|
|
// 初始化小学、初中和高中各三个账号
|
|
|
|
|
// 小学账户
|
|
|
|
|
USER_ACCOUNTS.put("张三1", new UserInfo("张三1", "123", "小学"));
|
|
|
|
|
USER_ACCOUNTS.put("张三2", new UserInfo("张三2", "123", "小学"));
|
|
|
|
|
USER_ACCOUNTS.put("张三3", new UserInfo("张三3", "123", "小学"));
|
|
|
|
|
userAccounts.put("张三1", new UserInfo("张三1", "123", "小学"));
|
|
|
|
|
userAccounts.put("张三2", new UserInfo("张三2", "123", "小学"));
|
|
|
|
|
userAccounts.put("张三3", new UserInfo("张三3", "123", "小学"));
|
|
|
|
|
|
|
|
|
|
// 初中账户
|
|
|
|
|
USER_ACCOUNTS.put("李四1", new UserInfo("李四1", "123", "初中"));
|
|
|
|
|
USER_ACCOUNTS.put("李四2", new UserInfo("李四2", "123", "初中"));
|
|
|
|
|
USER_ACCOUNTS.put("李四3", new UserInfo("李四3", "123", "初中"));
|
|
|
|
|
userAccounts.put("李四1", new UserInfo("李四1", "123", "初中"));
|
|
|
|
|
userAccounts.put("李四2", new UserInfo("李四2", "123", "初中"));
|
|
|
|
|
userAccounts.put("李四3", new UserInfo("李四3", "123", "初中"));
|
|
|
|
|
|
|
|
|
|
// 高中账户
|
|
|
|
|
USER_ACCOUNTS.put("王五1", new UserInfo("王五1", "123", "高中"));
|
|
|
|
|
USER_ACCOUNTS.put("王五2", new UserInfo("王五2", "123", "高中"));
|
|
|
|
|
USER_ACCOUNTS.put("王五3", new UserInfo("王五3", "123", "高中"));
|
|
|
|
|
userAccounts.put("王五1", new UserInfo("王五1", "123", "高中"));
|
|
|
|
|
userAccounts.put("王五2", new UserInfo("王五2", "123", "高中"));
|
|
|
|
|
userAccounts.put("王五3", new UserInfo("王五3", "123", "高中"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
@ -93,7 +93,7 @@ public class MathExamGenerator {
|
|
|
|
|
String password = parts[1];
|
|
|
|
|
// 验证用户登录
|
|
|
|
|
boolean loginSuccess = false;
|
|
|
|
|
for (Map.Entry<String, UserInfo> entry : USER_ACCOUNTS.entrySet()) {
|
|
|
|
|
for (Map.Entry<String, UserInfo> entry : userAccounts.entrySet()) {
|
|
|
|
|
if (entry.getValue().getUsername().equals(username) &&
|
|
|
|
|
entry.getValue().getPassword().equals(password)) {
|
|
|
|
|
currentUser = entry.getValue();
|
|
|
|
@ -165,7 +165,6 @@ public class MathExamGenerator {
|
|
|
|
|
// 生成不重复的题目
|
|
|
|
|
private static List<String> generateUniqueQuestions(int questionCount) {
|
|
|
|
|
List<String> questions = new ArrayList<>();
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
int attempts = 0;
|
|
|
|
|
int maxAttempts = questionCount * 3; // 最多尝试次数,避免死循环
|
|
|
|
|
|
|
|
|
|