This commit is contained in:
Jan-Philipp Luithardt
2025-12-03 15:04:30 +01:00
parent 835bd912df
commit 21a95a8388
31 changed files with 99 additions and 33 deletions

View File

@@ -2,7 +2,9 @@ package hhn.temp.project;
import hhn.temp.project.expections.TaskAlreadyExistsException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TaskManager {
@@ -24,4 +26,19 @@ public class TaskManager {
taskMap.put(task.getTaskID(), task);
return task;
}
public List<Task> getTaskList() {
return new ArrayList<>(this.taskMap.values());
}
public Task getTask(String name) {
return taskMap.values().stream().filter(t -> t.getName().equals(name)).findFirst()
.orElseThrow(() -> new IllegalArgumentException("Wrong name"));
}
public Task getTask(int taskID) {
if(!this.taskMap.containsKey(taskID)) {
throw new IllegalArgumentException("Wrong id");
}
return this.taskMap.get(taskID);
}
}