Compare commits

...

2 Commits

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 { public static void main(String[] args) throws IOException {
var service = new TaskService(new InMemoryTaskRepository()); var service = new TaskService(new InMemoryTaskRepository());
var cli = new CliEngine(service); var cli = new CliEngine(service);
// service.create("test has-id");
// System.out.println(service.has(2));
cli.start(); cli.start();
} }

View File

@ -30,4 +30,8 @@ public class InMemoryTaskRepository implements TaskRepository {
public void delete(int id) { public void delete(int id) {
storage.remove(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(); List<Task> findAll();
void delete(int id); void delete(int id);
boolean has(int id);
} }

View File

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