public static void RunProgram() { GetAverageAge(); GetUserAge(); Display(); foreach (var item in QuestionnaireLogic.indexTable) { Console.WriteLine(YesOrNoQuestionLogic.AddYesOrNo(item.QuestionToAsk, item.QuestionType)); if (item.DataTypes == Models.DataTypes.Integer) { var number = Console.ReadLine(); while (!int.TryParse(number, out value) || value > ValueQuestionLogic._maxValueAllowed || value < _minValue) { Console.WriteLine($"\nError....Please enter a valid number between {_minValue} - {ValueQuestionLogic._maxValueAllowed}"); number = Console.ReadLine(); } QuestionnaireLogic.AgeCalculation(item.Id, value); } else if (item.DataTypes == Models.DataTypes.StringValue) { if (item.QuestionType == Models.QuestionType.YesOrNoQuestion) { var reply = Console.ReadLine().ToLower(); while (!reply.Equals(YesOrNoQuestionLogic._positiveResponse) && !reply.Equals(YesOrNoQuestionLogic._negativeResponse)) { Console.WriteLine($"Please enter {YesOrNoQuestionLogic._positiveResponse} or {YesOrNoQuestionLogic._negativeResponse}."); reply = Console.ReadLine().ToLower(); } QuestionnaireLogic.AgeCalculation(item.Id, reply); } } } DisplayFinalAge(); }
public static double AgeCalculation(int id, string value) { return(_averageAge += YesOrNoQuestionLogic.AgeCalculation(id, value)); }