Adds setEmployees method

parent 519a1e73
package dgpena.siexample.persistence;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
......@@ -44,6 +45,22 @@ public class Project {
return employees;
}
public void setEmployees(Collection<Employee> employees) {
// remove my employees that are not in the new list of employees
for (Employee e: this.getEmployees()) {
if (!employees.contains(e)) {
this.removeEmployee(e);
}
}
// add all the new employees
for (Employee e: employees) {
if (!this.getEmployees().contains(e)) {
this.addEmployee(e, new Date());
}
}
}
public void addEmployee(Employee e, Date startDate) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment