Beispiel #1
0
 private int CalculateGameWithHighestGoalDifference(FootballGame[] footballStage)
 {
     int highestGoalDifference = 0;
     int gameWithHighestGoalDifference = 0;
     for (int i = 0; i < footballStage.Length; i++)
     {
         int gameGoalDifference = GetGoalDifferenceInAGame(footballStage[i].scoreTeam1, footballStage[i].scoreTeam2);
         if (gameGoalDifference > highestGoalDifference)
         {
             highestGoalDifference = gameGoalDifference;
             gameWithHighestGoalDifference = i;
         }
     }
     return gameWithHighestGoalDifference;
 }
Beispiel #2
0
 private int CalculateAverageGoalsForThisStage(FootballGame[] footballStage)
 {
     int totalGoals = CalculateTotalGoals(footballStage);
     return totalGoals / footballStage.Length;
 }
Beispiel #3
0
 private FootballGame[] AddLastGame(FootballGame[] footballStage, FootballGame[] lastGame)
 {
     Array.Resize(ref footballStage, footballStage.Length + 1);
     lastGame.CopyTo(footballStage, footballStage.Length - 1);
     return footballStage;
 }
Beispiel #4
0
        private FootballGame[] RemoveWeakestGame(FootballGame[] footballStage)
        {
            int gameWithHighestGoalDifference = CalculateGameWithHighestGoalDifference(footballStage);
            int lenghtToCopy = footballStage.Length - gameWithHighestGoalDifference -1;
            Array.ConstrainedCopy(footballStage, gameWithHighestGoalDifference + 1, footballStage, gameWithHighestGoalDifference, lenghtToCopy);
            Array.Resize(ref footballStage, footballStage.Length - 1);

               return footballStage;
        }
Beispiel #5
0
 private int CalculateTotalGoals(FootballGame[] footballStage)
 {
     int totalGoals = 0;
     for (int i = 0; i < footballStage.Length; i++)
     {
         totalGoals += footballStage[i].scoreTeam1 + footballStage[i].scoreTeam2;
     }
     return totalGoals;
 }
Beispiel #6
0
        private string CalculateLowestGoalRatio(FootballGame[] footballStage)
        {
            string teamWithLowestGameRatio = string.Empty;
            teamWithLowestGameRatio = footballStage[0].team1;
            float lowestGameRatio = GetLowestRatio(footballStage[0].scoreTeam1, footballStage[0].scoreTeam2);
            for (int i = 0; i < footballStage.Length; i++)
            {
                float team1Ratio = GetLowestRatio(footballStage[i].scoreTeam1, footballStage[i].scoreTeam2);
                float team2Ratio = GetLowestRatio(footballStage[i].scoreTeam2, footballStage[i].scoreTeam1);

                if (team1Ratio <= team2Ratio && team1Ratio < lowestGameRatio)
                {
                    lowestGameRatio = team1Ratio;
                    teamWithLowestGameRatio = footballStage[i].team1;
                } else if (team2Ratio < lowestGameRatio)
                {
                    lowestGameRatio = team2Ratio;
                    teamWithLowestGameRatio = footballStage[i].team2;
                }

            }

            return teamWithLowestGameRatio;
        }