예제 #1
0
void AssignmentList::insert(Assignment inputAssignment)
{

    if (!obtainSize()) // If the list is empty.
        theData.push_front(inputAssignment);

    else
    {

        for (AssignmentIterator = theData.begin();
            AssignmentIterator != theData.end();
            AssignmentIterator++)
        {

            // If we find an assignment with a later due date, insert this
                // assignment before it and exit the function.
            if (inputAssignment.obtainDueDate() <= AssignmentIterator->obtainDueDate())
            {
                theData.insert(AssignmentIterator, inputAssignment);
                // Reference: "std::list::insert." _cplusplus.com_.
                    // cplusplus.com, 2015. Web. 2 Oct. 2015.
                    // <http://www.cplusplus.com/reference/list/list/insert/>.
                return;
            }

        }

        theData.push_back(inputAssignment);
        // If we have not found an assignment with a later due date, place
            // this assignment at the end of the list.

    }

}
예제 #2
0
bool AssignmentList::addAssignment(Assignment inputAssignment)
{
    if (inputAssignment.hasInvalidDate())
        return false;
    if (!find(inputAssignment)) // Look for assignment with same assigned date.
    {
        if (!(inputAssignment.obtainDueDate() <=
            inputAssignment.obtainAssignedDate()))
        {
            insert(inputAssignment);
            if (inputAssignment.obtainStatus() == 2)
                lateAssignments++; // Keep track of late assignments.
            return true;
        }
    }
    return false;
}