예제 #1
0
        public double GetPlayerAverage(Player player, IEnumerable<WeeklyScore> scores)
        {
            List<WeeklyScore> scoresForPlayer = scores.Where(s => s.Player.Equals(player) && !s.Absent).ToList();
            double average = player.InitialAverage;

            if (scoresForPlayer.Count > 0)
            {
                double totalPins = scoresForPlayer.Sum(s => s.Total);
                average = Math.Round(totalPins / (3 * scoresForPlayer.Count), 0, MidpointRounding.AwayFromZero);
            }

            return average;
        }
        private WeeklyScore CreateWeeklyScore(int game1, int game2, int game3, Player player, Team team, Week week)
        {
            WeeklyScore score = A.Fake<WeeklyScore>();
            score.Game1 = game1;
            score.Game2 = game2;
            score.Game3 = game3;
            score.Player = player;
            score.Team = team;
            score.Week = week;

            return score;
        }
예제 #3
0
 private void UpdateSelectedGridPlayer(Player selectedGridPlayer)
 {
     PlayerName = selectedGridPlayer.Name;
     PlayerId = selectedGridPlayer.Id;
 }
예제 #4
0
        public int GetTotalGamesWithPinsBetween200And250ForPlayer(Player player, List<WeeklyScore> scores)
        {
            int totalGamesWithPinsBetween200And250ForPlayer = 0;

            foreach (WeeklyScore weeklyScore in
                scores.Where(weeklyScore => weeklyScore.Player.Equals(player) && !weeklyScore.Absent))
            {
                if (IsGameBetween200And250(weeklyScore.Game1))
                {
                    totalGamesWithPinsBetween200And250ForPlayer++;
                }
                if (IsGameBetween200And250(weeklyScore.Game2))
                {
                    totalGamesWithPinsBetween200And250ForPlayer++;
                }
                if (IsGameBetween200And250(weeklyScore.Game3))
                {
                    totalGamesWithPinsBetween200And250ForPlayer++;
                }
            }

            return totalGamesWithPinsBetween200And250ForPlayer;
        }
예제 #5
0
 public int GetTotalGamesForPlayer(Player player, List<WeeklyScore> scores)
 {
     return scores.Where(weeklyScore => weeklyScore.Player.Equals(player) && !weeklyScore.Absent).Sum(weeklyScore => 3);
 }
예제 #6
0
        public int GetTotalGamesWithPinsOver250ForPlayer(Player player, List<WeeklyScore> scores)
        {
            int totalGamesWithPinsOver250ForPlayer = 0;

            foreach (WeeklyScore weeklyScore in scores)
            {
                if (weeklyScore.Player.Equals(player) && !weeklyScore.Absent)
                {
                    if (IsGameOver250(weeklyScore.Game1))
                    {
                        totalGamesWithPinsOver250ForPlayer++;
                    }
                    if (IsGameOver250(weeklyScore.Game2))
                    {
                        totalGamesWithPinsOver250ForPlayer++;
                    }
                    if (IsGameOver250(weeklyScore.Game3))
                    {
                        totalGamesWithPinsOver250ForPlayer++;
                    }
                }
            }

            return totalGamesWithPinsOver250ForPlayer;
        }