Ejemplo n.º 1
0
        public void StartSentenceGame(ConsoleView _view, GameController controller, SentenceDB _sentencedb)
        {
            _view.Countdown();
            TimeSpan startTime   = StartTimer();
            int      wordCounter = 1;

            while (wordCounter <= 5)
            {
                Sentence sentence1      = _sentencedb.GetRandomSentence(Difficulty);
                string   randomSentence = sentence1.SentenceString;
                controller.TotalSentenceLength += sentence1.SentenceLength;

                _view.PrintSentence(wordCounter, randomSentence);
                string   sentence      = Console.ReadLine();
                string[] sentenceArray = sentence.Split(' ');

                int mistakes = GetMistakes(sentenceArray, randomSentence);

                controller.TotalMistakes += mistakes;
                Console.WriteLine("Number of mistakes: " + mistakes);
                Console.WriteLine();
                wordCounter++;
            }
            TimeSpan endTime     = EndTimer();
            TimeSpan elapsedTime = endTime - startTime;

            _view.EndGamePrinter(elapsedTime, controller.TotalMistakes, controller.TotalSentenceLength);

            Console.Clear();
            StartSentenceGame(_view, new GameController(), _sentencedb);
        }
Ejemplo n.º 2
0
        public void StartSentenceGame(ConsoleView _view, GameController controller, SentenceDB _sentencedb)
        {
            _view.Countdown();
            TimeSpan startTime = StartTimer();
            int wordCounter = 1;

            while (wordCounter <= 5)
            {
                Sentence sentence1 = _sentencedb.GetRandomSentence(Difficulty);
                string randomSentence = sentence1.SentenceString;
                controller.TotalSentenceLength += sentence1.SentenceLength;

                _view.PrintSentence(wordCounter, randomSentence);
                string sentence = Console.ReadLine();
                string[] sentenceArray = sentence.Split(' ');

                int mistakes = GetMistakes(sentenceArray, randomSentence);

                controller.TotalMistakes += mistakes;
                Console.WriteLine("Number of mistakes: " + mistakes);
                Console.WriteLine();
                wordCounter++;
            }
            TimeSpan endTime = EndTimer();
            TimeSpan elapsedTime = endTime - startTime;

            _view.EndGamePrinter(elapsedTime, controller.TotalMistakes, controller.TotalSentenceLength);

            Console.Clear();
            StartSentenceGame(_view, new GameController(), _sentencedb);
        }