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


C# Statistics.AddGameResult方法代码示例

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


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

示例1: okButton_Click

        protected void okButton_Click(object sender, EventArgs e)
        {
            //Game game = new Game();

            //game.Play();

            //Dart dart = new Dart(random);
            //dart.Throw();

            //resultLabel.Text = String.Format("Dart landed on {0} with ringmultiplier {1}x", dart.Score, dart.RingMultiplier);

            int games = 9999999;

            Statistics player1Stats = new Statistics(games);
            Statistics player2Stats = new Statistics(games);

            for (int i = 0; i < player1Stats.Length; i++)
            {
                Game game = new Game();
                game.Play();

                if (game.Player1Score > game.Player2Score)
                {
                    player1Stats.AddGameResult(1);
                    player2Stats.AddGameResult(0);
                }
                else
                {
                    player1Stats.AddGameResult(0);
                    player2Stats.AddGameResult(1);
                }
            }

            //string winningPlayer = "";
            //if (game.Player1Score > game.Player2Score)
            //{
            //    winningPlayer = "Player 1";
            //}
            //else
            //    winningPlayer = "Player 2";

            resultLabel.Text = String.Format("Player 1 won : {0}% of the time.<br/>Player 2 won : {1}% of the time.<br/>",
                player1Stats.GetWinPercentage().ToString(),
                player2Stats.GetWinPercentage().ToString());

            //resultLabel.Text = String.Format("Player 1: {0}<br/>Player 2: {1}<br/>{2} wins!",
            //    game.Player1Score,
            //    game.Player2Score,
            //    winningPlayer);
        }
开发者ID:jollyfitguy,项目名称:Projects,代码行数:50,代码来源:Default.aspx.cs


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