예제 #1
0
        /// <summary>
        /// It formats the players score, capitalizing only the first letter of Player's name.
        /// </summary>
        /// <param name="record">
        /// Player's score.
        /// </param>
        /// <returns>
        /// Player's score as a string, with only the first letter of Player's name capitalized.
        /// </returns>
        public string Format(IPersonalScore record)
        {
            string playerName = this.CapitalizeFirstLetter(record.Name);
            string result = string.Format("{0} ---> {1} mistake(s)!", playerName, record.Score);

            return result;
        }
예제 #2
0
        /// <summary>
        /// It formats the players score with all letters in Uppercase.
        /// </summary>
        /// <param name="record">
        /// Player's score.
        /// </param>
        /// <returns>
        /// Player's score as string, formatted with all letters in Uppercase.
        /// </returns>
        public string Format(IPersonalScore record)
        {
            if (record == null)
            {
                throw new ArgumentNullException("record", "Incorrect IPersonalScore");
            }

            string playerName = this.CapitalizeAllLetters(record.Name);
            string result = string.Format("{0} ---> {1} MISTAKE(S)!", playerName, record.Score);

            return result;
        }
예제 #3
0
 public override void SaveResult(IPersonalScore newRecord)
 {
     base.SaveResult(newRecord);
     DataFileManager.SingletonInstance.SaveResult(newRecord, Constants.DatabaseFile);
 }
예제 #4
0
 /// <summary>
 /// Saves results. Can be overridden by inheritors.
 /// </summary>
 /// <param name="newRecord">
 /// Player's personal score.
 /// </param>
 public virtual void SaveResult(IPersonalScore newRecord)
 {
     this.ScoreBoardService.AddNewScore(newRecord);
 }
예제 #5
0
 /// <summary>
 /// Saves the received IPersonalScore in the database.
 /// </summary>
 /// <param name="score">
 /// The score of the current player.
 /// </param>
 /// <param name="filePath">
 /// The path to the file, which acts as a database.
 /// </param>
 public override void SaveResult(IPersonalScore score, string filePath)
 {
     using (StreamWriter writer = new StreamWriter(filePath, true))
     {
         writer.WriteLine(score);
     }
 }
예제 #6
0
 /// <summary>
 /// Saves the received IPersonalScore in the database.
 /// </summary>
 /// <param name="score">
 /// The score of the current player.
 /// </param>
 /// <param name="filePath">
 /// The path to the file, which acts as a database.
 /// </param>
 public abstract void SaveResult(IPersonalScore score, string filePath);
예제 #7
0
 /// <summary>
 /// Adds new IPersonalScore to the collection contained in the 
 /// IScoreBoard that it currently works with.
 /// </summary>
 /// <param name="record">Instance of IPersonalScore</param>
 public void AddNewScore(IPersonalScore record)
 {
     this.currentScoreBoard.Records.Add(record);
 }