Exemple #1
0
        /// <summary>
        /// Adds new instance of Score to the list of scores and saves the list
        /// </summary>
        /// <param name="playersName"></param>
        /// <param name="rightAnswers"></param>
        /// <param name="prize"></param>
        /// <param name="questionSets"></param>
        /// <returns></returns>
        public string AddScore(string playersName, int rightAnswers, PrizeMoney prize, List <string> questionSets)
        {
            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 0; i < questionSets.Count() - 1; i++)
            {
                stringBuilder.Append(questionSets[i]);
                stringBuilder.Append(", ");
            }
            stringBuilder.Append(questionSets[questionSets.Count() - 1]);

            Scores.Add(new Score(playersName, rightAnswers, prize, stringBuilder.ToString()));
            Scores = Scores.OrderByDescending(x => x.Prize.Value).ToList();

            try
            {
                FileManager.SaveScores(Scores);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return(null);
        }
Exemple #2
0
 public GameManager(List <QSet> selectedQSets) : base(selectedQSets)
 {
     Prize = new PrizeMoney();
 }