Example #1
0
 public void AddStatistics(LevelStatistics statistics)
 {
     if (statistics == null)
         throw new ArgumentNullException("statistics");
     if (!statistics.Complited)
         throw new Exception("Level is not complited.");
     if (_levelStatisticses.ContainsKey(statistics.Level))
     {
         if (_levelStatisticses[statistics.Level].TypingSpeed < statistics.TypingSpeed)
             _levelStatisticses[statistics.Level] = statistics;
     }
     else
     {
         _levelStatisticses[statistics.Level] = statistics;
     }
 }
Example #2
0
 private void Finish()
 {
     _finished = true;
     _finishTime = DateTime.Now;
     var elapsedTime = _finishTime - _startTime;
     var typingSpeed = new TypingSpeed(_level.Text.Length, elapsedTime);
     var isSucceed = _errorsNumber <= _level.MaxErrorsNumber && typingSpeed >= _level.MinTypingSpeed;
     var levelStatistics = new LevelStatistics(_level, _errorsNumber, typingSpeed, isSucceed);
     OnFinished(new EventArgs<LevelStatistics>(levelStatistics));
 }