diff --git a/src/MathExamGenerator.class b/src/MathExamGenerator.class index 909c0b1..dd4a12c 100644 Binary files a/src/MathExamGenerator.class and b/src/MathExamGenerator.class differ diff --git a/src/MathExamGenerator.java b/src/MathExamGenerator.java index 172f4d6..4beeee2 100644 --- a/src/MathExamGenerator.java +++ b/src/MathExamGenerator.java @@ -27,7 +27,7 @@ import java.util.Set; */ public class MathExamGenerator { // 预设的用户账号信息 - private static final Map USER_ACCOUNTS = new HashMap<>(); + private static final Map 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 entry : USER_ACCOUNTS.entrySet()) { + for (Map.Entry 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 generateUniqueQuestions(int questionCount) { List questions = new ArrayList<>(); - Random random = new Random(); int attempts = 0; int maxAttempts = questionCount * 3; // 最多尝试次数,避免死循环