Beispiel #1
0
 public static Risk CalculateRiskProfile2(Age age) =>
 (age < 60) ? Risk.Low : Risk.Medium;
Beispiel #2
0
        // dishonest fn transformed to a honest fn
        //public static Risk CalculateRiskProfile(int age)
        //{
        //    if (age < 0 || 120 <= age)
        //        throw new ArgumentException($"{age} is not a valid age");
        //    return (age < 60) ? Risk.Low : Risk.Medium;
        //}

        // honest fn
        public static Risk CalculateRiskProfile(Age age, Gender gender)
        {
            var threshold = (gender == Gender.Female) ? 62 : 60;

            return((age < threshold) ? Risk.Low : Risk.Medium);
        }