Skip to content
Snippets Groups Projects
Commit f7a12fad authored by Rafi Zereselasie (raz070)'s avatar Rafi Zereselasie (raz070)
Browse files

Implemented getEmployeeShiftByWeek.

parent dce3321d
No related branches found
No related tags found
No related merge requests found
......@@ -259,8 +259,33 @@ public class Model {
return output;
}
//todo
void getEmployeeShiftsByWeek(){
ArrayList<String> getEmployeeShiftsByWeek(int employeeID, String startOfWeek, String endOfWeek){
String[] startSplit = startOfWeek.split("-");
String[] endSplit = endOfWeek.split("-");
ArrayList<String> output = new ArrayList<>();
for(String shift: this.shifts){
if(!shift.equals("allShifts")){
String[] shiftSplit = shift.split("\\.");
String[] dateSplit = shiftSplit[1].split("-");
try {
if(Integer.parseInt(shiftSplit[0]) == employeeID){
if(Integer.parseInt(startSplit[0]) >= Integer.parseInt(dateSplit[0]) &&
Integer.parseInt(startSplit[1]) >= Integer.parseInt(dateSplit[1]) &&
Integer.parseInt(startSplit[2]) >= Integer.parseInt(dateSplit[2])){
if(Integer.parseInt(endSplit[0]) >= Integer.parseInt(dateSplit[0]) &&
Integer.parseInt(endSplit[1]) >= Integer.parseInt(dateSplit[1]) &&
Integer.parseInt(endSplit[2]) >= Integer.parseInt(dateSplit[2])){
output.add(shift);
}
}
}
} catch (Exception e){
System.out.println("Error: Parsing string to int");
}
}
}
return output;
}
void logOut() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment