package pdm;

import java.util.Set;

public class Task {

	private String name;
	private int duration;
	private int earliestStart;
	private int earliestFinish;
	private int latestStart;
	private int latestFinish;
	private Set<Task> dependencies;
	private boolean isCompleted;

	public Task(String name, int duration, Set<Task> dependencies) {
		this.name = name;
		this.duration = duration;
		this.earliestStart = 0;
		this.earliestFinish = 0;
		this.latestStart = 0;
		this.latestFinish = 0;
		this.dependencies = dependencies;
		this.isCompleted = false;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Task " + getName() + "\n");
		builder.append("Duration: " + getDuration() + "\n");
		builder.append("Earliest start: " + getEarliestStart() + "\n");
		builder.append("Earliest finish: " + getEarliestFinish() + "\n");
		builder.append("Latest start: " + getLatestStart() + "\n");
		builder.append("Latest finish: " + getLatestFinish() + "\n");
		if (getDependencies().size() > 0) {
			builder.append("Dependencies: ");
			for (Task dep : getDependencies()) {
				builder.append(dep.getName() + " ");
			}
		} else
			builder.append("No dependencies.");
		
		builder.append("\n");
		return builder.toString(); // TODO
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getDuration() {
		return duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}

	public int getEarliestStart() {
		return earliestStart;
	}

	public void setEarliestStart(int earliestStart) {
		this.earliestStart = earliestStart;
	}

	public int getEarliestFinish() {
		return earliestFinish;
	}

	public void setEarliestFinish(int earliestFinish) {
		this.earliestFinish = earliestFinish;
	}

	public int getLatestStart() {
		return latestStart;
	}

	public void setLatestStart(int latestStart) {
		this.latestStart = latestStart;
	}

	public int getLatestFinish() {
		return latestFinish;
	}

	public void setLatestFinish(int latestFinish) {
		this.latestFinish = latestFinish;
	}

	public Set<Task> getDependencies() {
		return dependencies;
	}

	public void setDependencies(Set<Task> dependencies) {
		this.dependencies = dependencies;
	}

	public void addDependency(Task dependency) {
		this.dependencies.add(dependency);
	}

	public void removeDependency(Task dependency) {
		this.dependencies.remove(dependency);
	}

	public boolean isCompleted() {
		return isCompleted;
	}

	public void setIsCompleted(boolean isCompleted) {
		this.isCompleted = isCompleted;
	}
}
@@ -7,16 +7,42 @@
 e pdm;%0A%0A
+import java.util.HashSet;%0A
 import j
@@ -55,16 +55,16 @@
 il.Set;%0A
-
 %0Apublic 
@@ -265,16 +265,46 @@
 encies;%0A
+%09private Set%3CTask%3E nextTasks;%0A
 %09private
@@ -578,16 +578,56 @@
 encies;%0A
+%09%09this.nextTasks = new HashSet%3CTask%3E();%0A
 %09%09this.i
@@ -1310,11 +1310,9 @@
 %22);%0A
-%09%09
 %0A
+
 %09%09bu
@@ -1363,16 +1363,8 @@
 g();
- // TODO
 %0A%09%7D%0A
@@ -2314,24 +2314,24 @@
 ndencies) %7B%0A
-
 %09%09this.depen
@@ -2350,32 +2350,253 @@
 pendencies;%0A%09%7D%0A%0A
+%09public Set%3CTask%3E getNextTasks() %7B%0A%09%09return nextTasks;%0A%09%7D%0A%0A%09public void addNextTask(Task nextTask) %7B%0A%09%09this.nextTasks.add(nextTask);%0A%09%7D%0A%0A%09public void removeNextTask(Task nextTask) %7B%0A%09%09this.nextTasks.remove(nextTask);%0A%09%7D%0A%0A
 %09public void add

To compute the latest finish time for each task, we need to know about the tasks that depend on this task. So we have a list of "next tasks" :rocket: