Added Task Adding, Removing, Editing and corrected some relatex tests. Coverage still not 100%
This commit is contained in:
@@ -7,13 +7,15 @@ import java.util.Map;
|
||||
|
||||
public class AssignmentManager {
|
||||
Map<Integer, Worker> workerMap;
|
||||
List<Task> taskList;
|
||||
Map<Integer, Task> taskMap;
|
||||
int workerIdCounter;
|
||||
int taskIdCounter;
|
||||
|
||||
public AssignmentManager() {
|
||||
workerMap = new HashMap<>();
|
||||
taskList = new ArrayList<>();
|
||||
taskMap = new HashMap<>();
|
||||
int workerIdCounter = 1000;
|
||||
int taskIdCounter = 0;
|
||||
}
|
||||
|
||||
public int createWorker(String name) {
|
||||
@@ -22,18 +24,34 @@ public class AssignmentManager {
|
||||
return workerIdCounter;
|
||||
}
|
||||
public int addTask(int workerId, String name, String description) {
|
||||
return 0;
|
||||
if (!workerMap.containsKey(workerId) || name == null || description == null) {
|
||||
throw new IllegalArgumentException("WorkerId must exist and name or description can't be null");
|
||||
}
|
||||
Task task = new Task(++taskIdCounter, workerId, name, description, this);
|
||||
taskMap.put(taskIdCounter, task);
|
||||
return taskIdCounter;
|
||||
}
|
||||
public Task getTask(int taskId) {
|
||||
return null;
|
||||
if (!taskMap.containsKey(taskId)) {
|
||||
throw new IllegalArgumentException("Task Id does not exist");
|
||||
}
|
||||
return taskMap.get(taskId);
|
||||
}
|
||||
public ArrayList<Task> getTaskList() {
|
||||
return null;
|
||||
public Map<Integer, Task> getTaskMap() {
|
||||
return taskMap;
|
||||
}
|
||||
public void editTask(int workerId, int taskId, String name, String description) {
|
||||
|
||||
if (!workerMap.containsKey(workerId) || !taskMap.containsKey(taskId)) {
|
||||
throw new IllegalArgumentException("Task Id or Worker Id does not exist");
|
||||
}
|
||||
Task task = taskMap.get(taskId);
|
||||
task.setName(name);
|
||||
task.setDescription(description);
|
||||
}
|
||||
public void removeTask(int taskId) {
|
||||
|
||||
if (!taskMap.containsKey(taskId)) {
|
||||
throw new IllegalArgumentException("Task Id does not exist");
|
||||
}
|
||||
taskMap.remove(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user