Skip to content

Commit ceae47e

Browse files
committed
Adds now todo checked to the todo files
1 parent 27acf4d commit ceae47e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main/java/org/ainm/controllers/todolist/TodoitemController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ void setTodo(String todo) {
1515
String getTodo() {
1616
return checkBox.getText();
1717
}
18-
}
18+
19+
Boolean isDone() {
20+
return checkBox.isChecked()
21+
}
22+
}

src/main/java/org/ainm/controllers/todolist/TodolistController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ void saveFile(Path file) throws IOException {
7373
String saveData = "";
7474
for(Node todoItem:todos_list.getChildren()) {
7575
TodoitemController controller = (TodoitemController) getController(todoItem);
76-
saveData += controller.getTodo() + "\n";
76+
saveData += "[" + ((controller.isDone() ? "x":" ") + "]" + controller.getTodo() + "\n";
7777
}
7878
//Save this string to the given file
7979
Files.writeString(file, saveData);
8080
}
81+
8182
public static Object getController(Node node) {
8283
Object controller = null;
8384
do {
@@ -86,4 +87,4 @@ public static Object getController(Node node) {
8687
} while (controller == null && node != null);
8788
return controller;
8889
}
89-
}
90+
}

0 commit comments

Comments
 (0)