Пример #1
0
        //adds the name of the players and their score to a list in sorted order
        public static void AddNameAndScore(string name, int score)
        {
            HighScore newHS = new HighScore(name, score);

            if (IsHighScore(score))
            {
                if (HighScoreList.Count >= 5)
                {
                    HighScoreList.RemoveAt(HighScoreList.Count - 1);
                }
                HighScoreList.Add(newHS);
                HighScoreList.Sort();
            }
        }
Пример #2
0
 //checks if new score is greater than lowest score. returns bool.
 public static bool IsHighScore(int score)
 {
     HighScoreList.Sort();
     return(HighScoreList.Count < 5 || score > HighScoreList[HighScoreList.Count - 1].Score);
 }