This commit is contained in:
Jan-Philipp Luithardt
2025-12-03 14:19:26 +01:00
parent 62745621f9
commit 835bd912df
36 changed files with 90 additions and 36 deletions

View File

@@ -1,5 +1,7 @@
package hhn.temp.project;
import hhn.temp.project.expections.TaskAlreadyExistsException;
import java.util.HashMap;
import java.util.Map;
@@ -12,9 +14,14 @@ public class TaskManager {
}
public Task createTask(String name, String description) {
boolean taskExited = this.taskMap.values().stream().anyMatch(task -> task.getName().equals(name));
if(taskExited) {
throw new TaskAlreadyExistsException("Task already exits, with the name: " + name);
}
Task task = new Task(name, description);
taskMap.put(task.getTaskID(), task);
return task;
}
}

View File

@@ -0,0 +1,8 @@
package hhn.temp.project.expections;
public class TaskAlreadyExistsException extends RuntimeException {
public TaskAlreadyExistsException(String message) {
super(message);
}
}