public void SetTotalMarks(decimal? totalMarks)
{
if (totalMarks.HasValue)
{
if (totalMarks.Value < 1)
{
throw new ArgumentOutOfRangeException("totalMarks", "Total marks value must be greater than zero.");
}
if (this.results.Any(r => r.Result > totalMarks))
{
throw new ArgumentOutOfRangeException(
"totalMarks", "All results must be within than the total marks");
}
}
this.TotalMarks = totalMarks;
}