private int PrintAssignments(ISpreadsheetWriter spreadsheetWriter) { int lastQuestionRow = 0; var totalAssignments = TotalAssignments.Count(); for (int assignmentIndex = 0; assignmentIndex < totalAssignments; assignmentIndex++) { Assignment assignment = TotalAssignments.ElementAt(assignmentIndex); spreadsheetWriter.MoveDownTimes(assignment.NumberOfQuestions); AssignmentBottomRows.Add(spreadsheetWriter.CurrentPosition.Y); bool isLastAssignmentReached = assignmentIndex == totalAssignments - 1; if (isLastAssignmentReached) { lastQuestionRow = spreadsheetWriter.CurrentPosition.Y; } } return(lastQuestionRow); }