当前位置: 首页>>代码示例>>C#>>正文


C# Statistics.NewSeasonAverageStatistic方法代码示例

本文整理汇总了C#中Statistics.NewSeasonAverageStatistic方法的典型用法代码示例。如果您正苦于以下问题:C# Statistics.NewSeasonAverageStatistic方法的具体用法?C# Statistics.NewSeasonAverageStatistic怎么用?C# Statistics.NewSeasonAverageStatistic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statistics的用法示例。


在下文中一共展示了Statistics.NewSeasonAverageStatistic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTeamStatistics

        public virtual Statistics GetTeamStatistics(Team team)
        {
            var stats = new Statistics();

                var seasons = _seasonRepository.GetAll();
                foreach (var season in seasons)
                {
                    var hasCountedSeason = false;
                    var average = stats.NewSeasonAverageStatistic(season.Name);
                    foreach (var race in season.Races)
                    {
                        var entries = race.Entries.Where(re => re.Entrant.Team.Id == team.Id);
                        foreach (var entry in entries)
                            if (entry != null)
                            {
                                stats.Entered += 1;
                                stats.Poles += entry.QualifyingPosition == 1 ? 1 : 0;
                                stats.Wins += entry.RacePlace == 1 ? 1 : 0;
                                stats.Podiums += entry.RacePlace <= 3 ? 1 : 0;
                                stats.Finished += entry.DidNotFinish ? 0 : 1;
                                stats.Points += (int) entry.Points;

                                if (!entry.DidNotQualify)
                                    average.AddQualifyingResult(entry.QualifyingPosition);

                                if (entry.HasFinished)
                                    average.AddRaceResult(entry.RacePlace);

                                if (!hasCountedSeason)
                                {
                                    stats.Seasons += 1;
                                    hasCountedSeason = true;
                                }
                            }

                        var seasonResult = season.GetTeamStandings().SingleOrDefault(e => e.Entrant.Team.Id == team.Id);

                        if (seasonResult != null)
                        {
                            if (seasonResult.Position < stats.BestChampionshipResult)
                                stats.BestChampionshipResult = seasonResult.Position;
                        }
                    }
                }

            return stats;
        }
开发者ID:robgray,项目名称:f1speedguides,代码行数:47,代码来源:Statistician.cs

示例2: GetDriverStatistics

        public virtual Statistics GetDriverStatistics(Driver driver)
        {
            var stats = new Statistics();
            var racerRatio = 0.0;

            foreach (var season in driver.Contracts.Select(c => c.Season))
            {
                if (!season.Entrants.Any(x => x.Driver.Id == driver.Id))
                    continue;

                bool hasCountedSeason = false;
                var average = stats.NewSeasonAverageStatistic(season.Name);
                foreach (var race in season.Races)
                {
                    var entry = race.Entries.FirstOrDefault(re => re.Entrant.Driver.Id == driver.Id);
                    if (entry != null)
                    {
                        if (entry.RacerRatio != null)
                            racerRatio += entry.RacerRatio.Value;

                        stats.Entered += 1;
                        if (season.Year >= 4) stats.FastestLapsEntered += 1;
                        stats.Poles += entry.QualifyingPosition == 1 ? 1 : 0;
                        stats.Wins += entry.RacePlace == 1 ? 1 : 0;
                        stats.Podiums += entry.RacePlace <= 3 ? 1 : 0;
                        stats.Finished += entry.DidNotFinish ? 0 : 1;
                        stats.Points += (int) entry.Points;
                        stats.FastestLaps += race.GotFastestLap(driver) ? 1 : 0;

                        if (!entry.DidNotQualify)
                            average.AddQualifyingResult(entry.QualifyingPosition);

                        if (entry.HasFinished)
                            average.AddRaceResult(entry.RacePlace);

                        if (!hasCountedSeason)
                        {
                            stats.Seasons += 1;
                            hasCountedSeason = true;
                        }
                    }

                    var seasonResult =
                        season.GetDriverStandings().FirstOrDefault(e => e.Entrant.Driver.Id == driver.Id);

                    if (seasonResult != null)
                    {
                        if (seasonResult.Position < stats.BestChampionshipResult)
                            stats.BestChampionshipResult = seasonResult.Position;
                    }
                }
            }

            stats.RacerRatio = racerRatio / stats.Entered;

            return stats;
        }
开发者ID:robgray,项目名称:f1speedguides,代码行数:57,代码来源:Statistician.cs


注:本文中的Statistics.NewSeasonAverageStatistic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。