修改目录结构,精简项目

修改部分注释
main
lensfrex 3 years ago
parent 4ccb974d59
commit 222d88d5ad
Signed by: lensfrex
GPG Key ID: 0F69A0A2FBEE98A0
  1. 30
      pom.xml
  2. 7
      src/main/java/me/lensfrex/manager/Main.java
  3. 7
      src/main/java/me/lensfrex/manager/Worker.java
  4. 24
      src/main/java/me/lensfrex/manager/data/manager/StudentManager.java
  5. 8
      src/main/java/me/lensfrex/manager/sqlite/DataTypes.java
  6. 99
      src/main/java/me/lensfrex/manager/sqlite/SQLiteTool.java
  7. 3
      src/main/resources/META-INF/MANIFEST.MF
  8. 1
      src/main/resources/me/lensfrex/manager/cnHelpMessage.txt
  9. 1
      src/main/resources/me/lensfrex/manager/helpMessage.txt
  10. 0
      src/main/resources/me/lensfrex/manager/studentInformationExample.txt

@ -4,23 +4,27 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>StudentManagerS</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>me.lensfrex.smanager-s</groupId>
<artifactId>SManager-S</artifactId>
<version>0.0.1p</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<mainClass>me.lensfrex.manager.Main</mainClass>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -14,10 +14,7 @@ public class Main {
private void run() {
while (parseCommand(consoleTool.getUserInput()) != -1) {
System.out.println(
"----------------------------------------------------------------\n" +
" Please enter your choice:"
);
System.out.print("----------------------------------------------------------------\n" + " Please enter your choice:\n--> ");
}
}
@ -94,7 +91,7 @@ public class Main {
worker.printCnHelp();
break;
default:
System.out.println("- Don't recognize... Please enter again. (Enter 12 to show help again)");
System.out.println("Don't recognize... Please enter again. (Enter 12 to show help again)");
break;
}
return 0;

@ -1,6 +1,5 @@
package me.lensfrex.manager;
import me.lensfrex.manager.Main;
import me.lensfrex.manager.data.Student;
import me.lensfrex.manager.data.manager.StudentManager;
import me.lensfrex.manager.utils.IOUtil;
@ -10,9 +9,9 @@ import java.util.ArrayList;
public class Worker {
public static final String helpMessage = IOUtil.inputStreamToString(Main.class.getResourceAsStream("/me.lensfrex.manager/helpMessage.txt"), StandardCharsets.UTF_8);
public static final String cnHelpMessage = IOUtil.inputStreamToString(Main.class.getResourceAsStream("/me.lensfrex.manager/cnHelpMessage.txt"), StandardCharsets.UTF_8);
public static final String studentInformationExample = IOUtil.inputStreamToString(Main.class.getResourceAsStream("/me.lensfrex.manager/studentInformationExample.txt"), StandardCharsets.UTF_8);
public static final String helpMessage = IOUtil.inputStreamToString(Main.class.getResourceAsStream("/me/lensfrex/manager/helpMessage.txt"), StandardCharsets.UTF_8);
public static final String cnHelpMessage = IOUtil.inputStreamToString(Main.class.getResourceAsStream("/me/lensfrex/manager/cnHelpMessage.txt"), StandardCharsets.UTF_8);
public static final String studentInformationExample = IOUtil.inputStreamToString(Main.class.getResourceAsStream("/me/lensfrex/manager/studentInformationExample.txt"), StandardCharsets.UTF_8);
private final StudentManager studentManager = new StudentManager();

@ -22,7 +22,7 @@ public class StudentManager {
/**
* 增添学生输入的字符串格式应为 [id] [name] ...[subjectName,score]
* 23333333 Lag English,100 Math,99 History,98
* 2333 LagSeeing English,100 Math,99 History,98
*
* @param input 待添加的学生信息
*/
@ -152,7 +152,7 @@ public class StudentManager {
/**
* 按学生总分由高到低生成名次表
*
* @return 名次表字符串
* @return 按顺序记录的名次表ArrayList
*/
public ArrayList<String> generateRankingTable() {
ArrayList<String> rankingTable = new ArrayList<>();
@ -174,7 +174,7 @@ public class StudentManager {
/**
* 按学生学号由小到大生成成绩表
*
* @return 成绩表字符串
* @return 按学号顺序记录的成绩表ArrayList
*/
public ArrayList<String> generateScoreTableById() {
ArrayList<String> scoreTable = new ArrayList<>();
@ -188,9 +188,9 @@ public class StudentManager {
}
/**
* 按学生学号由小到大生成成绩表
* 按学生姓名由小到大生成成绩表
*
* @return 成绩表字符串
* @return 按姓名顺序记录的成绩表ArrayList
*/
public ArrayList<String> generateScoreTableByName() {
ArrayList<String> scoreTable = new ArrayList<>();
@ -207,7 +207,7 @@ public class StudentManager {
* 获取学生信息条目
*
* @param student 欲获取学生
* @return 学生信息
* @return 学生信息字符串
*/
public String getStudentInfo(Student student) {
StringBuilder stringBuilder = new StringBuilder();
@ -241,7 +241,7 @@ public class StudentManager {
/**
* 列出所有科目的成绩信息包括总分平均分
*
* @return 信息字符串
* @return 含有科目成绩信息记录的ArrayList
*/
public ArrayList<String> generateAllSubjectInfo() {
ArrayList<String> subjects = this.getSubjects();
@ -317,23 +317,23 @@ public class StudentManager {
* 获取某科目成绩分析HashMap
*
* @param subject 欲分析的科目
* @return 成绩等级人数
* @return 成绩等级人数数组长度为5对应ABCDE五个等级
*/
private int[] getSubjectAnalysis(String subject) {
ArrayList<Integer> scores = new ArrayList<>(managerTool.getSubjectScores(subject).values());
int[] scoreAnalysis = new int[5];
int[] scoreLevelStudentNumber = new int[5];
for (int score : scores) {
scoreAnalysis[getScoreLevel(score)]++;
scoreLevelStudentNumber[getScoreLevel(score)]++;
}
return scoreAnalysis;
return scoreLevelStudentNumber;
}
/**
* 获取所有成绩分析HashMap
*
* @return 成绩等级人数
* @return 包含有成绩等级人数的HashMapkey为科目名称value为层次人数数组
*/
public HashMap<String, int[]> getAllSubjectAnalysis() {
ArrayList<String> subjects = managerTool.getAllSubjects();

@ -1,8 +0,0 @@
package me.lensfrex.manager.sqlite;
public class DataTypes {
public static final String SQL_DATA_TYPE_NUMBER = "int";
public static final String SQL_DATA_TYPE_TEXT = "text";
public static final String SQL_DATA_TYPE_REAL = "real";
public static final String SQL_DATA_TYPE_NULL = "null";
}

@ -1,99 +0,0 @@
package me.lensfrex.manager.sqlite;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* SQL操作的简单封装...
* 试图手动封装SQL操作...
* 有BUG这就对了
* SQL语句仍在学习中...
* SQL语句拼接怎么这么麻烦...
*/
public class SQLiteTool {
private static final String DATABASE_LOCATION = "student.db";
private Connection dbConnection;
private Statement statement;
/**
* 初始化数据库文件若成功则返回true若数据库初始化出现异常则返回false
* 不保证数据库中存在欲操作的表需手动确认
*
* @return 初始化是否成功若成功则返回true若数据库初始化出现异常则返回false
*/
public boolean initDatabase() {
try {
Class.forName("org.sqlite.JDBC");
this.dbConnection = DriverManager.getConnection("jdbc:sqlite:" + DATABASE_LOCATION);
this.statement = dbConnection.createStatement();
return true;
} catch (Exception e) {
System.out.println("Some errors happens when initialing database.");
e.printStackTrace();
return false;
}
}
/**
* 向数据库中创建一个表
*
* @param tableName 数据库表的名称
* @param columns 数据库表列的参数map中key为列的名称value为其相应的数据类型
* @throws SQLException 如果创建表的过程中发生错误
*/
public void createTable(String tableName, HashMap<String, String> columns) throws SQLException {
StringBuilder stringBuilder = new StringBuilder("create table %s (");
for (Map.Entry<String, String> column : columns.entrySet()) {
stringBuilder.append(String.format("%s %s, ", column.getKey(), column.getValue()));
}
String createStatement = stringBuilder
.replace(stringBuilder.lastIndexOf(","), stringBuilder.lastIndexOf(",") + 2, ")")
.toString();
statement.executeUpdate(createStatement);
}
/**
* 查询表格是否存在
*
* @param tableName 表格名
* @return 存在返回true否则返回false
*/
public boolean isTableExists(String tableName) {
String tryStatement = String.format("select * from %s", tableName);
try {
statement.executeQuery(tryStatement);
return true;
} catch (Exception e) {
return false;
}
}
/**
* 向数据库里插入一条记录
*
* @param table 表格名
* @param values 每一列的数据值文本类型数据应使用单引号 ' 括住
* @throws SQLException 如果执行的过程中发生错误
*/
public void insert(String table, String... values) throws SQLException {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("insert into ").append(table).append(" values ( ");
for (String value : values) {
stringBuilder.append(value).append(' ');
}
stringBuilder.append(")");
statement.executeUpdate(stringBuilder.toString());
}
}

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: me.lensfrex.manager.Main

@ -1,5 +1,6 @@
----------------------------------------------------------------
欢迎来到 SManager-S
源代码:https://git.ciduid.top/lensfrex/SManager-S
----------------------------------------------------------------
您想做什么:
1. 添加学生

@ -1,5 +1,6 @@
----------------------------------------------------------------
Welcome to SManager-S
Source code: https://git.ciduid.top/lensfrex/SManager-S
----------------------------------------------------------------
Do you want to:
1. Input record
Loading…
Cancel
Save