Добавлен метод markTaskCompletedById для пометки задачи как выполненной по её идентификатору. Обновлён код в методе main для демонстрации работы нового метода. Это улучшает управление задачами в приложении. Closes #3
This commit is contained in:
parent
3197600a75
commit
67abdaefe1
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user