Added Tests for TaskState Changes. Actually added functionality to pass that test.

This commit is contained in:
2025-12-03 19:20:24 +01:00
parent 20daf315ca
commit 7640b1ef35
33 changed files with 122 additions and 59 deletions

View File

@@ -54,4 +54,19 @@ public class AssignmentManager {
}
taskMap.remove(taskId);
}
public void finishTask(int workerId, int taskId) {
if (!workerMap.containsKey(workerId) || !taskMap.containsKey(taskId)) {
throw new IllegalArgumentException("Task Id or Worker Id does not exist");
}
Task task = taskMap.get(taskId);
task.setTaskState(TaskState.FINISHED);
}
public void unfinishTask(int workerId, int taskId) {
if (!workerMap.containsKey(workerId) || !taskMap.containsKey(taskId)) {
throw new IllegalArgumentException("Task Id or Worker Id does not exist");
}
Task task = taskMap.get(taskId);
task.setTaskState(TaskState.IN_PROGRESS);
}
}

View File

@@ -6,12 +6,14 @@ public class Task {
int taskId;
int workerId;
AssignmentManager manager;
TaskState state;
public Task(int taskId, int workerId, String name, String description, AssignmentManager manager) {
this.manager = manager;
this.name = name;
this.description = description;
this.taskId = taskId;
this.workerId = workerId;
this.state = TaskState.IN_PROGRESS;
}
public String getName() {
@@ -32,5 +34,11 @@ public class Task {
public int getWorkerId() {
return workerId;
}
public void setTaskState(TaskState state) {
this.state = state;
}
public TaskState getTaskState() {
return state;
}
}