private void DisplayResult(Game game) { resultLabel.Text = ""; resultLabel.Text = String.Format("{0}: {1}</br>{2}: {3}</br>Winner: {4}", game.Player1.Name, game.Player1.Score, game.Player2.Name, game.Player2.Score, game.Winner); }
protected void okButton_Click1(object sender, EventArgs e) { Game game = new Game("Player1", "Player2"); game.GameStart(); DisplayResult(game); }
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); }
private void performGame() { Game game = new Game(); game.performGame(); resultLabel.Text = String.Format("<p>Player 1 Score: {0}, Player 2 Score {1}</p>", game.Player1Score, game.Player2Score); if (game.Player1Score > game.Player2Score) { resultLabel.Text += "Player 1 Wins!"; } else { resultLabel.Text += "Player 2 Wins!"; } }
protected void okButton_Click(object sender, EventArgs e) { Game game = new Game("Marcie", "Bob"); while (game.player1.Score <300 && game.player2.Score <300) game.ThrowDarts(); string winner; if (game.player1.Score > game.player2.Score) { winner = game.player1.Name; } else { winner = game.player2.Name; } resultLabel.Text = String.Format("{0}: {1} <br /> {2}: {3} <br /> {4} wins!", game.player1.Name, game.player1.Score, game.player2.Name, game.player2.Score, winner); }