I have trouble to figure out where is the problem in my code. I have employee array list, assignment array list. The goal is to add availableEmpAry only those employees, which skill array contains all required skills and is available on the time of shift. The problem is, after I have found employee with required skills. When starting second loop, it does not check the if an employee is available on that time. It jumps always to else and displays the message box. I will appreciate any suggestion and critic, as this is my very first post.
for (int j=0; j<empAry.size(); j++)
{
//Checking if employee skill array has an exact skill for cs
if (empAry.get(j).empSkillAry.containsAll(tempShift.Schedule.skillRequiredAry))
{
for(int i=0; i<assignmentAry.size();i++)
{
if(assignmentAry.get(i).employee.equals(empAry.get(j)))
{
Date shiftStart= tempShift.Start;
Date shiftEnd=tempShift.End;
Date empAsStart=assignmentAry.get(i).Start;
Date empAsEnd=assignmentAry.get(i).End;
if(empAsStart.before(shiftEnd) && empAsEnd.after(shiftStart))
{
JOptionPane.showMessageDialog(availableEmp, "No Available Employee!");
}else{
availableEmpAry.add(empAry.get(j));
availableEmp.setModel(
new DefaultComboBoxModel<Object>(availableEmpAry.toArray())
);
}
}else{
availableEmpAry.add(empAry.get(j));
availableEmp.setModel(
new DefaultComboBoxModel<Object>( availableEmpAry.toArray())
);
}
}//closing assignment loop
}else{
JOptionPane.showMessageDialog(availableEmp, "No employee with required skill!");
}
} // closing loop for employee
Aucun commentaire:
Enregistrer un commentaire