public FootballMatch ConstructMatch(string matchInput) { Match match = matchStringFormat.Match(matchInput); if (match.Success) { FootballMatch machResult = new FootballMatch(); machResult.HostTeam = match.Groups[1].Value; machResult.GuestTeam = match.Groups[2].Value; machResult.NumberOfGoalsScoredByHosts = Byte.Parse(match.Groups[3].Value); machResult.NumberOfGoalsScoredByGuests = Byte.Parse(match.Groups[4].Value); return machResult; } else { throw new ArgumentException("Invalid match format"); } }
public void AddPointsAndGoals(FootballMatch match, TeamResultsSummary hostResults, TeamResultsSummary guestResults) { if (match.NumberOfGoalsScoredByHosts > match.NumberOfGoalsScoredByGuests) { hostResults.Points += NumerOfPointForWin; } else if (match.NumberOfGoalsScoredByHosts < match.NumberOfGoalsScoredByGuests) { guestResults.Points += NumerOfPointForWin; } else { hostResults.Points += NumerOfPointForDraw; guestResults.Points += NumerOfPointForDraw; } hostResults.GoalsScored += match.NumberOfGoalsScoredByHosts; hostResults.GoalsLost += match.NumberOfGoalsScoredByGuests; guestResults.GoalsScored += match.NumberOfGoalsScoredByGuests; guestResults.GoalsLost += match.NumberOfGoalsScoredByHosts; }