// here we want parameter to change the base class as we dont know which type will derive from the base class. // we know its ploymorphic based on the type of object we are working with at that given time. private static void EnterGoalStats(IStatisticsData statisticsData) { while (true) { Console.WriteLine("Enter a Goal Stat or Enter a 'q' to quit."); var input = Console.ReadLine(); if (input == "q") { break; } try { var goalStat = double.Parse(input); statisticsData.AddGoalsFromMatch(goalStat); } // These two errors I know can occur here. Write try catch blocks for errors you know you need to handle. // Catches if value is out of the range in AddGoalsFromMatch() catch (ArgumentException ex) { Console.WriteLine(ex.Message); } // Catches if value is not in the correct format AddGoalsFromMatch() catch (FormatException ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine("**"); } } }
/// <summary> /// TODO /// </summary> public void Finish() { // calculate sum double sum = _totalPositive + _totalNegative; // set result Result = new DefaultStatistics(_totalPositive, _totalNegative, sum); }
public StatisticsProcessor(IStatisticsData statisticsData, IStatisticsHandler statisticsHandler) : this() { this.statisticsData = statisticsData; this.statisticsHandler = statisticsHandler; }
public StatisticsHandler(IStatisticsData statisticsData) : this() { this.statisticsData = statisticsData; }
/// <summary> /// TODO /// </summary> public EntriesStatisticsViewModel(IStatisticsData statisticsData) { StatisticsData = statisticsData ?? new EmptyStatisticsData(); }