feature/tasks/methods-and-statics #16

Merged
KamaSK merged 3 commits from feature/tasks/methods-and-statics into main 2025-05-19 14:42:09 +03:00
Showing only changes of commit 67abdaefe1 - Show all commits

View File

@ -8,6 +8,7 @@ public class TodoApp {
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
/*
* System.out.println("\n\nDeveloper mode:\n\n");
*
@ -15,6 +16,8 @@ public class TodoApp {
* Task t2 = new Task("Дело тест - t2", "");
* Task t3 = new Task("Дело тест - t3", "");
* printAll(t1, t2, t3);
* System.out.println(markTaskCompletedById(new Task[] { t1, t2, t3 }, 2));
* printAll(t1, t2, t3);
*
* System.out.println("\n\n" + "*".repeat(20) + "\n\n");
*/
@ -162,4 +165,14 @@ public class TodoApp {
t.printInfo();
}
private static boolean markTaskCompletedById(Task[] tasks, int id) {
for (Task t : tasks)
if (t != null && t.getId() == id) {
if (!t.getCompleted())
t.toggleCompleted();
return true;
}
return false;
}
}