コード例 #1
0
ファイル: TakeQuizMenu.cs プロジェクト: senaszel/SD_13_QUIZ
        private void TakeQuiz(object quizId)
        {
            double results   = 0;
            var    questions = SQLiteDataAccess.SelectQuestionsByQuizesId((int)quizId);


            foreach (var question in questions)
            {
                bool usersAnswer = AskEachQuestionOneAtTheTime(question);

                if (usersAnswer)
                {
                    results += 1;
                    Console.WriteLine("\n\tIt is a correct answer!\n");
                }
                else
                {
                    Console.WriteLine("\n\tYyyyy!!\tWrong!\n");
                }

                Console.ReadKey();
            }

            Console.Clear();

            Console.WriteLine("\n\n\tYour Quiz ended");
            Console.WriteLine($"\n\t\tU scored : {Math.Round((results*100)/questions.Count)} % !");

            Console.ReadKey();
        }
コード例 #2
0
ファイル: InsertMenu.cs プロジェクト: senaszel/SD_13_QUIZ
        private void FullQuiz(object obj)
        {
            AddNewQuiz(null);
            int exitCode;

            do
            {
                AskOneQuestionAndItsAnswersAtTheTime();
                Menu.Menu yesNoMenu = new YesNoMenu();
                exitCode = yesNoMenu.Start();
            } while (exitCode != 0);

            QuizModel            latestQuiz     = SQLiteDataAccess.SelectLatestQuiz();
            List <QuestionModel> questionsCount = SQLiteDataAccess.SelectQuestionsByQuizesId(latestQuiz.Id);

            Console.WriteLine($"{questionsCount.Count} x Questions Have Been Added To Quiz: {latestQuiz.Name}");
            Console.ReadKey();
        }