         self.workEstimate = workEstimate
         self.workSessions = []
         self.dropped = false
-    }
-    
+        self.isComplete = false
+    }
+
     func addWorkSession(dayScheduledOn: WorkDay, amountOfWork: Float) {
         let workSession = TaskWorkSession(self, dayScheduledOn: dayScheduledOn, amountOfWork: amountOfWork)
         self.workSessions.append(workSession)
         dayScheduledOn.workSessions.append(workSession)
     }
-    
+
+    func completedWorkSession(workSession: TaskWorkSession) {
+        if workSession.parentTask === self {
+            workSession.hasBeenCompleted = true
+            if self.workCompleted >= self.workLeftToDo {
+                self.isComplete = true
+            }
+        } else {
+            // Normally I would just throw something but that's acting funny in a playground
+            dateFormatter.dateFromString("garbage")!
+        }
+    }
+
     var totalWorkScheduled: Float {
         return self.workSessions.map({ $0.amountOfWork }).reduce(0.0, combine: +)
     }
-    
+
     var workNotScheduled: Float {
         return self.workEstimate - self.totalWorkScheduled
     }
-    
+
     var workCompleted: Float {
         return self.workSessions.filter({ $0.hasBeenCompleted }).map({ $0.amountOfWork }).reduce(0.0, combine: +)
     }
-    
+
     var workLeftToDo: Float {
         return self.workEstimate - self.workCompleted
     }

            let newWorkDay = WorkDay(date: date, totalAvailableWork: self.workAvailableOnDate(date))
            self.workDays.append(newWorkDay)
            self.workDays.sortInPlace({ $0.date.compare($1.date) == .OrderedAscending })
            
            return newWorkDay
        }
    }
    
    func workDayBeforeDay(day: WorkDay) -> WorkDay {
        return self.workDayForDate(day.date.dateByAddingTimeInterval(-24 * 60 * 60))
    }
    
    func workDayAfterDay(day: WorkDay) -> WorkDay {
        return self.workDayForDate(day.date.dateByAddingTimeInterval(24 * 60 * 60))
    }
    
    func availableWorkTimeBetweenNowAnd(date date: NSDate) -> Float {
        var currentDay: NSDate? = now.copy() as? NSDate
        var totalAvailableWorkTime: Float = 0.0
        
        while currentDay!.compare(date) == .OrderedAscending {
            let workDay = self.workDayForDate(currentDay!)
            totalAvailableWorkTime += workDay.totalAvailableWork
            currentDay = currentDay!.dateByAddingTimeInterval(24 * 60 * 60)
        }
        
        return totalAvailableWorkTime
    }
    
    func workToDoBetweenNowAnd(date date: NSDate) -> Float {
        return self.notDroppedTasks.filter({ $0.dueDate.compare(date) != .OrderedDescending }).map({ $0.workLeftToDo }).reduce(0.0, combine: +)
    }
    
    var droppedTasks: [Task] {
        return tasks.filter({ $0.dropped })
    }
    
    var notDroppedTasks: [Task] {
        return tasks.filter({ !$0.dropped })
    }
}


user.tasks.append(Task(title: "Long Task 1", dueDate: dateFormatter.dateFromString("2015-10-05")!, priority: 3, workEstimate: 10.0))
user.tasks.append(Task(title: "Long Task 2", dueDate: dateFormatter.dateFromString("2015-10-06")!, priority: 4, workEstimate: 12.0))

// Schedule these tasks and print the schedule

scheduleTasksForUser(user)
user.droppedTasks
printScheduleForUser(user)

// Change the work estimate of Medium Tak 4 so it schedules

//medTask4.workEstimate = 2.0
scheduleTasksForUser(user)
user.droppedTasks
print("\n----------\n")
printScheduleForUser(user)

