diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..dc0b01f
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,84 @@
+
+
+ 4.0.0
+
+ com.mathquiz
+ MathQuizApp
+ 1.0.0
+ jar
+
+ Math Quiz Application
+ 小初高数学学习软件 - Swing版本
+
+
+ UTF-8
+ 21
+ 21
+
+
+
+
+
+ com.google.code.gson
+ gson
+ 2.10.1
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.11.0
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.3.0
+
+
+
+ com.mathquiz.Main
+ true
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.5.1
+
+
+ package
+
+ shade
+
+
+
+
+ com.mathquiz.Main
+
+
+ MathQuizApp
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/MathQuiz/Main.java b/src/main/java/com/MathQuiz/Main.java
new file mode 100644
index 0000000..49ac2f4
--- /dev/null
+++ b/src/main/java/com/MathQuiz/Main.java
@@ -0,0 +1,4 @@
+package com.MathQuiz;
+
+public class Main {
+}
diff --git a/src/main/java/com/model/ChoiceQuestion.java b/src/main/java/com/model/ChoiceQuestion.java
new file mode 100644
index 0000000..e4b0b54
--- /dev/null
+++ b/src/main/java/com/model/ChoiceQuestion.java
@@ -0,0 +1,74 @@
+package com.model;
+
+import java.util.List;
+
+//选择题
+public class ChoiceQuestion {
+
+ private String questionText; // 题目文本
+ private Object correctAnswer; // 正确答案
+ private List> options; // 选项列表
+ private Grade grade; // 所属学段
+
+
+
+ public ChoiceQuestion(String questionText, double correctAnswer,
+ List options, Grade grade) {
+ this.questionText = questionText;
+ this.correctAnswer = correctAnswer;
+ this.options = options;
+ this.grade = grade;
+ }
+
+ public ChoiceQuestion(String questionText, String correctAnswer,
+ List options, Grade grade) {
+ this.questionText = questionText;
+ this.correctAnswer = correctAnswer;
+ this.options = options;
+ this.grade = grade;
+ }
+
+
+
+ public String getQuestionText() {
+ return questionText;
+ }
+
+ public void setQuestionText(String questionText) {
+ this.questionText = questionText;
+ }
+
+ public Object getCorrectAnswer() {
+ return correctAnswer;
+ }
+
+ public void setCorrectAnswer(Object correctAnswer) {
+ this.correctAnswer = correctAnswer;
+ }
+
+ public List> getOptions() {
+ return options;
+ }
+
+ public void setOptions(List> options) {
+ this.options = options;
+ }
+
+ public Grade getGrade() {
+ return grade;
+ }
+
+ public void setGrade(Grade grade) {
+ this.grade = grade;
+ }
+
+ @Override
+ public String toString() {
+ return "ChoiceQuestion{" +
+ "questionText='" + questionText + '\'' +
+ ", correctAnswer=" + correctAnswer +
+ ", options=" + options +
+ ", grade=" + grade +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/model/Grade.java b/src/main/java/com/model/Grade.java
new file mode 100644
index 0000000..afa5077
--- /dev/null
+++ b/src/main/java/com/model/Grade.java
@@ -0,0 +1,9 @@
+package com.model;
+
+
+//学段
+public enum Grade {
+ ELEMENTARY, // 小学
+ MIDDLE, // 初中
+ HIGH // 高中
+}
\ No newline at end of file
diff --git a/src/main/java/com/model/QuizHistory.java b/src/main/java/com/model/QuizHistory.java
new file mode 100644
index 0000000..5bad9d0
--- /dev/null
+++ b/src/main/java/com/model/QuizHistory.java
@@ -0,0 +1,79 @@
+package com.model;
+
+
+import java.util.Date;
+import java.util.List;
+
+//答题历史记录模型
+public class QuizHistory {
+
+ private String username; // 用户名
+ private Date timestamp; // 答题时间
+ private List questions; // 题目列表
+ private List userAnswers; // 用户答案列表
+ private int score; // 得分
+
+
+ public QuizHistory(String username, Date timestamp,
+ List questions,
+ List userAnswers,
+ int score) {
+ this.username = username;
+ this.timestamp = timestamp;
+ this.questions = questions;
+ this.userAnswers = userAnswers;
+ this.score = score;
+ }
+
+
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public List getQuestions() {
+ return questions;
+ }
+
+ public void setQuestions(List questions) {
+ this.questions = questions;
+ }
+
+ public List getUserAnswers() {
+ return userAnswers;
+ }
+
+ public void setUserAnswers(List userAnswers) {
+ this.userAnswers = userAnswers;
+ }
+
+ public int getScore() {
+ return score;
+ }
+
+ public void setScore(int score) {
+ this.score = score;
+ }
+
+ @Override
+ public String toString() {
+ return "QuizHistory{" +
+ "username='" + username + '\'' +
+ ", timestamp=" + timestamp +
+ ", questions=" + (questions != null ? questions.size() : 0) +
+ ", score=" + score +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/model/QuizResult.java b/src/main/java/com/model/QuizResult.java
new file mode 100644
index 0000000..eb70db5
--- /dev/null
+++ b/src/main/java/com/model/QuizResult.java
@@ -0,0 +1,62 @@
+package com.model;
+
+
+//答题结果
+public class QuizResult {
+
+ private int totalQuestions; // 总题数
+ private int correctCount; // 正确题数
+ private int wrongCount; // 错误题数
+ private int score; // 得分
+
+
+ public QuizResult(int totalQuestions, int correctCount, int wrongCount, int score) {
+ this.totalQuestions = totalQuestions;
+ this.correctCount = correctCount;
+ this.wrongCount = wrongCount;
+ this.score = score;
+ }
+
+
+ public int getTotalQuestions() {
+ return totalQuestions;
+ }
+
+ public void setTotalQuestions(int totalQuestions) {
+ this.totalQuestions = totalQuestions;
+ }
+
+ public int getCorrectCount() {
+ return correctCount;
+ }
+
+ public void setCorrectCount(int correctCount) {
+ this.correctCount = correctCount;
+ }
+
+ public int getWrongCount() {
+ return wrongCount;
+ }
+
+ public void setWrongCount(int wrongCount) {
+ this.wrongCount = wrongCount;
+ }
+
+ public int getScore() {
+ return score;
+ }
+
+ public void setScore(int score) {
+ this.score = score;
+ }
+
+ @Override
+ public String toString() {
+ return "QuizResult{" +
+ "totalQuestions=" + totalQuestions +
+ ", correctCount=" + correctCount +
+ ", wrongCount=" + wrongCount +
+ ", score=" + score +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/model/User.java b/src/main/java/com/model/User.java
new file mode 100644
index 0000000..78d530a
--- /dev/null
+++ b/src/main/java/com/model/User.java
@@ -0,0 +1,115 @@
+package com.model;
+
+import java.util.Date;
+
+
+//用户
+public class User {
+
+ private String username; // 用户名
+ private String password; // 密码(加密后)
+ private String email; // 邮箱
+ private Grade grade; // 学段
+ private int totalQuizzes; // 总答题次数
+ private double averageScore; // 平均分
+ private Date registrationDate; // 注册时间
+
+
+
+ /**
+ * 完整构造方法(用于从文件加载)
+ */
+ public User(String username, String password, String email, Grade grade,
+ int totalQuizzes, double averageScore, Date registrationDate) {
+ this.username = username;
+ this.password = password;
+ this.email = email;
+ this.grade = grade;
+ this.totalQuizzes = totalQuizzes;
+ this.averageScore = averageScore;
+ this.registrationDate = registrationDate;
+ }
+
+ /**
+ * 简化构造方法(用于新用户注册)
+ */
+ public User(String username, String password, String email, Grade grade) {
+ this.username = username;
+ this.password = password;
+ this.email = email;
+ this.grade = grade;
+ this.totalQuizzes = 0;
+ this.averageScore = 0.0;
+ this.registrationDate = new Date();
+ }
+
+
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public Grade getGrade() {
+ return grade;
+ }
+
+ public void setGrade(Grade grade) {
+ this.grade = grade;
+ }
+
+ public int getTotalQuizzes() {
+ return totalQuizzes;
+ }
+
+ public void setTotalQuizzes(int totalQuizzes) {
+ this.totalQuizzes = totalQuizzes;
+ }
+
+ public double getAverageScore() {
+ return averageScore;
+ }
+
+ public void setAverageScore(double averageScore) {
+ this.averageScore = averageScore;
+ }
+
+ public Date getRegistrationDate() {
+ return registrationDate;
+ }
+
+ public void setRegistrationDate(Date registrationDate) {
+ this.registrationDate = registrationDate;
+ }
+
+ @Override
+ public String toString() {
+ return "User{" +
+ "username='" + username + '\'' +
+ ", email='" + email + '\'' +
+ ", grade=" + grade +
+ ", totalQuizzes=" + totalQuizzes +
+ ", averageScore=" + String.format("%.1f", averageScore) +
+ ", registrationDate=" + registrationDate +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/service/FileIOService.java b/src/main/java/com/service/FileIOService.java
new file mode 100644
index 0000000..4bfa68e
--- /dev/null
+++ b/src/main/java/com/service/FileIOService.java
@@ -0,0 +1,242 @@
+package com.service;
+
+
+import com.model.*;
+import com.util.FileUtils;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 文件IO服务
+ * 负责所有数据的读写操作
+ */
+public class FileIOService {
+
+ private static final String DATA_DIR = "data";
+ private static final String USERS_DIR = DATA_DIR + "/users";
+ private static final String HISTORY_DIR = DATA_DIR + "/history";
+
+ private static final String USERS_FILE = DATA_DIR + "/users.json";
+ private static final String CURRENT_USER_FILE = DATA_DIR + "/current_user.json";
+
+ private static final Gson gson = new GsonBuilder()
+ .setPrettyPrinting()
+ .setDateFormat("yyyy-MM-dd HH:mm:ss")
+ .create();
+
+ // ==================== 初始化 ====================
+
+ public void initDataDirectory() throws IOException {
+ FileUtils.createDirectoryIfNotExists(DATA_DIR);
+ FileUtils.createDirectoryIfNotExists(USERS_DIR);
+ FileUtils.createDirectoryIfNotExists(HISTORY_DIR);
+
+ if (!FileUtils.exists(USERS_FILE)) {
+ Map> data = new HashMap<>();
+ data.put("users", new ArrayList<>());
+ FileUtils.saveAsJson(data, USERS_FILE);
+ }
+
+ System.out.println("✓ 数据目录初始化完成");
+ }
+
+ // ==================== 用户操作 ====================
+
+ public void saveUser(User user) throws IOException {
+ Type type = new TypeToken