public ListIntensityHeartrate createModel(int age, int restingHeartrate) { ListIntensityHeartrate list = new ListIntensityHeartrate(); for (var i = 55; i <= 95; i = i + 5) { IntensityHeartrate intensityHeartrate = new IntensityHeartrate(); HeartrateCalculator calc = new HeartrateCalculator(); intensityHeartrate = calc.addHeartRateIntensity(age, restingHeartrate, i); list.ListOfIntensityHeartrates.Add(intensityHeartrate); } return(list); }
static void Main(string[] args) { bool notInt = true; int age = 0; int heartrate = 0; while (notInt) { Console.WriteLine("Please enter your age: "); try { age = Convert.ToInt32(Console.ReadLine()); Console.Clear(); Console.WriteLine("Please enter your resting heartrate"); try { heartrate = Convert.ToInt32(Console.ReadLine()); notInt = false; } catch { Console.Clear(); } } catch { Console.Clear(); } } HeartrateModelCreator modelCreator = new HeartrateModelCreator(); ListIntensityHeartrate model = new ListIntensityHeartrate(); model = modelCreator.createModel(age, heartrate); Console.Clear(); Console.WriteLine(string.Format("Age: {0} Resting Heart Rate: {1}", age, heartrate)); Console.WriteLine(""); Console.WriteLine("Intensity | Heartrate"); Console.WriteLine("---------------------"); foreach (var heartrateintensity in model.ListOfIntensityHeartrates) { Console.WriteLine(string.Format(" {0}% | {1}", heartrateintensity.Intensity, heartrateintensity.Heartrate)); } Console.ReadKey(); }