예제 #1
0
        /// <summary>
        /// Validate user input arguments.
        /// </summary>
        /// <param name="compareBy"></param>
        /// <returns></returns>
        private bool Validate(AgeCompareCriteria compareBy)
        {
            if (compareBy == AgeCompareCriteria.Undefined)
            {
                throw new ArgumentException("The comparison type criteria was not defined");
            }
            if (_people == null)
            {
                throw new ArgumentException("A list people were expected");
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Find the people whose ages differ according to the age comparison type criteria.
        /// </summary>
        /// <param name="compareBy">The age comparison type criteria</param>
        /// <returns></returns>
        private IEnumerable <Answer> SetAgeDifferences(AgeCompareCriteria compareBy)
        {
            Validate(compareBy);

            // Get comparison results
            var answerCandidates = _people.CombinationBuilder((a, b) => SetBirthdateInterval(a, b)).ToList <Answer>();

            if (answerCandidates.Count < 1)
            {
                return(new List <Answer>());
            }
            return(answerCandidates.ToList().OrderBy(a => a.AgeInterval));
        }