1. Users should be able to use to populate the following arrays:

Array Contents
Developer Contains the names of all the developers
assigned to tasks
Task Names Contains the names of all the created tasks
Task ID Contains the generated taskID’s for all tasks
Task Duration Contains the Duration of all tasks
Task Status Contains the Status of all tasks
2. Users should be able to use these arrays to:
a. Display the Developer, Task Names and Task Duration for all tasks with the status of
done.
b. Display the Developer and Duration of the class with the longest duration.
c. Search for a task with a Task Name and display the Task Name, Developer and Task
Status.
d. Search for all tasks assigned to a developer and display the Task Name and Task
Status.
e. Delete a task using the Task Name.
f. Display a report that lists the full details of all captured tasks.
in java

1 answer

Here is a possible implementation in Java:

```java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TaskManager {
private List<String> developers;
private List<String> taskNames;
private List<String> taskIds;
private List<Integer> taskDuration;
private List<String> taskStatus;

public TaskManager() {
developers = new ArrayList<>();
taskNames = new ArrayList<>();
taskIds = new ArrayList<>();
taskDuration = new ArrayList<>();
taskStatus = new ArrayList<>();
}

// Method to populate the arrays
public void addTask(String developer, String taskName, String taskId, int duration, String status) {
developers.add(developer);
taskNames.add(taskName);
taskIds.add(taskId);
taskDuration.add(duration);
taskStatus.add(status);
}

// Method to display tasks with status "Done"
public void displayDoneTasks() {
for (int i = 0; i < taskStatus.size(); i++) {
if (taskStatus.get(i).equals("Done")) {
System.out.println("Developer: " + developers.get(i));
System.out.println("Task Name: " + taskNames.get(i));
System.out.println("Task Duration: " + taskDuration.get(i));
}
}
}

// Method to display the developer and duration of the task with longest duration
public void displayLongestTask() {
int maxDuration = Integer.MIN_VALUE;
int maxIndex = -1;
for (int i = 0; i < taskDuration.size(); i++) {
if (taskDuration.get(i) > maxDuration) {
maxDuration = taskDuration.get(i);
maxIndex = i;
}
}
if (maxIndex != -1) {
System.out.println("Developer: " + developers.get(maxIndex));
System.out.println("Task Duration: " + taskDuration.get(maxIndex));
}
}

// Method to search for a task by name
public void searchTaskByName(String taskName) {
for (int i = 0; i < taskNames.size(); i++) {
if (taskNames.get(i).equals(taskName)) {
System.out.println("Task Name: " + taskNames.get(i));
System.out.println("Developer: " + developers.get(i));
System.out.println("Task Status: " + taskStatus.get(i));
break;
}
}
}

// Method to search for tasks assigned to a developer
public void searchTasksByDeveloper(String developerName) {
for (int i = 0; i < developers.size(); i++) {
if (developers.get(i).equals(developerName)) {
System.out.println("Task Name: " + taskNames.get(i));
System.out.println("Task Status: " + taskStatus.get(i));
}
}
}

// Method to delete a task by name
public void deleteTask(String taskName) {
for (int i = 0; i < taskNames.size(); i++) {
if (taskNames.get(i).equals(taskName)) {
developers.remove(i);
taskNames.remove(i);
taskIds.remove(i);
taskDuration.remove(i);
taskStatus.remove(i);
break;
}
}
}

// Method to display a report of all tasks
public void displayReport() {
for (int i = 0; i < developers.size(); i++) {
System.out.println("Developer: " + developers.get(i));
System.out.println("Task Name: " + taskNames.get(i));
System.out.println("Task ID: " + taskIds.get(i));
System.out.println("Task Duration: " + taskDuration.get(i));
System.out.println("Task Status: " + taskStatus.get(i));
System.out.println("-------------------");
}
}

public static void main(String[] args) {
TaskManager taskManager = new TaskManager();

// Populating the arrays
taskManager.addTask("Developer 1", "Task 1", "001", 4, "Done");
taskManager.addTask("Developer 2", "Task 2", "002", 3, "In Progress");
taskManager.addTask("Developer 3", "Task 3", "003", 6, "Done");
taskManager.addTask("Developer 1", "Task 4", "004", 5, "Done");
taskManager.addTask("Developer 2", "Task 5", "005", 2, "Done");

// Example usage of the methods
System.out.println("Done tasks:");
taskManager.displayDoneTasks();

System.out.println("Task with longest duration:");
taskManager.displayLongestTask();

System.out.println("Searching for task by name 'Task 3':");
taskManager.searchTaskByName("Task 3");

System.out.println("Tasks assigned to 'Developer 1':");
taskManager.searchTasksByDeveloper("Developer 1");

System.out.println("Deleting task 'Task 2':");
taskManager.deleteTask("Task 2");

System.out.println("All tasks in the report:");
taskManager.displayReport();
}
}
```

This is just one possible implementation, and it can be customized or modified based on specific requirements or preferences.