import java.util.ArrayList;

public class Attendance
{
    // package access for testing
    ArrayList<CourseRecord> historyList;
    ArrayList<CourseRecord> mathList;

    public int moreHistoryThanMathAbsences()
    {
        int moreHistory = 0;

        for(CourseRecord historyRecord : historyList)
        {
            int mathAbsences = -1;
            int mathIndex = 0;
            while(mathIndex < mathList.size() && mathAbsences == -1)
            {
                if(mathList.get(mathIndex).getStudentID().equals(
                        historyRecord.getStudentID()))
                {
                    mathAbsences = mathList.get(mathIndex).getAbsences();
                }

                mathIndex++;
            }

            if(mathAbsences != -1 && historyRecord.getAbsences() > mathAbsences)
                moreHistory++;
        }

        return moreHistory;
    }
}
