Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void) slotShifts
- {
- for (int loop = 0; loop < 5; loop++){
- BOOL result = TRUE;
- printf("------------------------+++++++++++LOOP:%i\n", loop);
- while (result) {
- result = FALSE;
- for (int y = 0; y < [empStorage count]; y++) // this cycles
- //through the employees
- {
- for (int x = 0; x < DAYCOUNT; x++) // change the 3 to 7 once
- //all days are allocated
- {
- BOOL plCheck = [self placementCheck:[[dayStorage objectAtIndex:x]
- objectAtIndex:0] withEmp:[[[empStorage objectAtIndex:y]
- objectAtIndex:6]intValue]];
- if (plCheck) { //checks if employee and shift are both
- //the same placement, i.e. FOH or BOH
- //for each shift
- for (int j = 1; j < [[dayStorage objectAtIndex:x]count];j++)
- {
- if ([[[dayStorage objectAtIndex:x] // checks if shift is available
- objectAtIndex:j]count] == 2) {
- if ([[[[empStorage objectAtIndex:y] // this checks if the employee is
- objectAtIndex:4] // available this day to work
- objectAtIndex:x]intValue]
- == 1) {
- BOOL curWorking = [self currentlyWorking:[[empStorage objectAtIndex:y]
- objectAtIndex:0]onDay:x andShift:j];
- //before and after test to see if employee is currently working
- if (!curWorking) {
- // this takes the shift's end time and subtracts the
- // start time to get the hours of a shift. Then it
- // adds the already accumulated hours the employee has
- int z =
- ([[[[dayStorage objectAtIndex:x]objectAtIndex:j]
- objectAtIndex:1]intValue] - [[[[dayStorage objectAtIndex:x]
- objectAtIndex:j]objectAtIndex:0]intValue]) +
- [[[empStorage objectAtIndex:y]objectAtIndex:5]intValue];
- // following if checks if max hours have been met
- if ( z <
- [[[empStorage objectAtIndex:y]objectAtIndex:1]intValue]) {
- //PAY ATTENTION
- //PAY ATTENTION
- //LOOK AT THIS
- //HERE IS THE PART THAT YOU NEED TO LOOK AT
- // this adds the employee at the scheduled time
- // IMPORTANT: everything after this point should be setting
- // new values rather than checks because the shift has
- // ALREADY BEEN SLOTTED
- [self addEmp:[empStorage objectAtIndex:y]
- toDay:[dayStorage objectAtIndex:x]
- toShift:j];
- printf(".\n");
- // this replaces the accumulated hours with the new total, z.
- [[empStorage objectAtIndex:y]replaceObjectAtIndex:5
- withObject:[NSNumber numberWithInt:z]];
- result = TRUE;
- //[self printTest];
- }//endif hrs max met
- } //endif currently working
- } //endif day available
- } //endif shift available
- } //end for each shift in day loop
- }//end if placement is correct
- }//end for each day in the week
- }//end for each employee
- }//end while loop
- }//end for loop of whole thing for redundancy
- }//end method
Add Comment
Please, Sign In to add comment