BalloonsPop.Highscore.HighscoreTable.AddPlayer C# (CSharp) Method

AddPlayer() public method

Adds a player to a HighscoreTable.
public AddPlayer ( PlayerScore score ) : void
score PlayerScore An instance of a class that implements the PlayerScore interface.
return void
        public void AddPlayer(PlayerScore score)
        {
            this.table.Add(score);
            this.table.Sort();

            if (this.table.Count > HighscoreTable.MaxPlayers)
            {
                this.table.RemoveAt(this.table.Count - 1);
            }
        }

Usage Example

Ejemplo n.º 1
0
 public void AddingPlayerToHighscoreTableShouldWorkCorrectly()
 {
     HighscoreTable table = new HighscoreTable();
     PlayerScore somePlayer = new PlayerScore("Pesho", 10, DateTime.Now);
     table.AddPlayer(somePlayer);
     Assert.AreEqual(1, table.Table.Count);
 }
All Usage Examples Of BalloonsPop.Highscore.HighscoreTable::AddPlayer