// add currentTask to day and currentTask.splitTaskPtr to nextDay
tasks.Add(curTask);
nextDay.removeTask(curTask);
nextDay.addTask(curTask.splitTaskPtr,0);
}
else{
break;
else
{
intcurTaskHours=curTask.duration;
if(curTask.isSplit)
{
curTask.splitTaskPtr.duration+=curTask.duration;
nextDay.nextDay.removeTask(curTask.splitTaskPtr);
// TODO: Get back to the above case
}
else
{
tasks.Add(curTask);
//day.nextDay.addTask(curTask, 0);
}
hours-=curTaskHours;
nextDay.removeTask(curTask);
}
}
}
// delete empty days
returntasks;
}
publicvoidmodifyWorkingHours(inthours)
{
inthoursPerDay=hours/days.Count;
// make the oneMore give more hours as we're approaching the dealine?
intoneMore=hours-hoursPerDay*days.Count-1;// to start counter i from 0
for(inti=0;i<days.Count;++i)
{
days[i].workingHours+=hoursPerDay;
if(i<=oneMore)
{
days[i].workingHours++;
}
}
returnhours<=0;
// now reorganize the tasks
// use reorderCalendar somehow?
// should iterate though the days resusivelt
// it should start iterating through the days from days[0] and add x hours of tasks then as we iterate through the days we add i * x amount of tasks to the days
// and if we gat to a point when for ex 16 hours need to be shifter we must recursively access the days to get the tasks
thrownewNoSpaceForTaskExeption("There is no space to add the task which needs to be added as the last task in the calendar",d,task,hours-task.duration);
}
returntrue;
}
publicvoidaddTask(Tasktask)
publicvoid_addTask(Tasktask)
{
List<Day>validDays=getRangeOfDaysForTask(task);
if(!isThereEnoughSpace(validDays,task)){
WriteLine("Not enough space");
return;
}
// Insert task
foreach(DaydayinvalidDays)
{
// TODO: Handle it in a different way
//if (day.tasks.Count != 0) {
for(inti=0;i<day.tasks.Count;++i){
// TODO: If equality optimize according to duration