文件结构更改
This commit is contained in:
parent
6c41a66593
commit
ad9e39d8bc
BIN
Java/Other/mysql-connector-j-8.4.0.jar
Normal file
BIN
Java/Other/mysql-connector-j-8.4.0.jar
Normal file
Binary file not shown.
7
Java/TodoListApp/.vscode/settings.json
vendored
Normal file
7
Java/TodoListApp/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
BIN
Java/TodoListApp/lib/mysql-connector-j-8.4.0.jar
Normal file
BIN
Java/TodoListApp/lib/mysql-connector-j-8.4.0.jar
Normal file
Binary file not shown.
0
Java/TodoListApp/src/DatabaseManager.java
Normal file
0
Java/TodoListApp/src/DatabaseManager.java
Normal file
@ -1,4 +1,4 @@
|
||||
package TodoListApp;
|
||||
package TodoListApp.src;
|
||||
public class EmptyDescriptionException extends Exception {
|
||||
public EmptyDescriptionException(String message){
|
||||
super(message);
|
@ -1,4 +1,4 @@
|
||||
package TodoListApp;
|
||||
package TodoListApp.src;
|
||||
public class InvalidIdException extends Exception {
|
||||
public InvalidIdException(String message){
|
||||
super(message);
|
@ -1,4 +1,4 @@
|
||||
package TodoListApp;
|
||||
package TodoListApp.src;
|
||||
// 待办事项类
|
||||
class TodoItem {
|
||||
private int id;
|
@ -1,4 +1,4 @@
|
||||
package TodoListApp;
|
||||
package TodoListApp.src;
|
||||
import java.util.Scanner;
|
||||
|
||||
// 主类
|
@ -1,4 +1,4 @@
|
||||
package TodoListApp;
|
||||
package TodoListApp.src;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
// 待办事项管理类
|
||||
class TodoListManager {
|
||||
private final List<TodoItem> todoList;
|
||||
@ -23,16 +22,10 @@ class TodoListManager {
|
||||
EmptyDescriptionException e = new EmptyDescriptionException("待办事项的描述不能为空。");
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
string sql = "insert into todos (description) values('"+description+"')"
|
||||
system.out.println(sql);
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.executeUpdate(sql)
|
||||
}
|
||||
TodoItem item = new TodoItem(nextId++, description);
|
||||
todoList.add(item);
|
||||
System.out.println("待办事项已添加: " + item);
|
||||
}o
|
||||
}
|
||||
|
||||
// 列出所有待办事项
|
||||
public void listTodos() {
|
@ -1,4 +1,4 @@
|
||||
package TodoListApp;
|
||||
package TodoListApp.src;
|
||||
public class TodoNotFoundException extends Exception {
|
||||
public TodoNotFoundException(String message){
|
||||
super(message);
|
Loading…
x
Reference in New Issue
Block a user