Добавлен метод has для проверки существования задачи в InMemoryTaskRepository и TaskService.

This commit is contained in:
KamaSK 2025-05-29 18:57:31 +03:00
parent 782325ecc8
commit 38ac198eb6
4 changed files with 14 additions and 0 deletions

View File

@ -10,6 +10,10 @@ public class TodoApp {
public static void main(String[] args) throws IOException {
var service = new TaskService(new InMemoryTaskRepository());
var cli = new CliEngine(service);
// service.create("test has-id");
// System.out.println(service.has(2));
cli.start();
}

View File

@ -30,4 +30,8 @@ public class InMemoryTaskRepository implements TaskRepository {
public void delete(int id) {
storage.remove(id);
}
public boolean has(int id) {
return storage.containsKey(id);
}
}

View File

@ -13,4 +13,6 @@ public interface TaskRepository {
List<Task> findAll();
void delete(int id);
boolean has(int id);
}

View File

@ -38,4 +38,8 @@ public class TaskService {
public void remove(int id) {
repo.delete(id);
}
public boolean has(int id) {
return repo.has(id);
}
}