コード例 #1
0
ファイル: ListQuestions.cs プロジェクト: Bismila/Millioner
        public OneQuestionAndAnswers ShuffleAnswers(OneQuestionAndAnswers oneQuest)
        {
            List <string> copyQuest = new List <string>();
            //OneQuestionAndAnswers copyQuest = new OneQuestionAndAnswers(oneQuest.Question,oneQuest.Answer1,
            //    oneQuest.Answer2, oneQuest.Answer3, oneQuest.Answer4, oneQuest.CorrectAnswer);
            int n = 4;

            copyQuest.Add(oneQuest.Answer1);
            copyQuest.Add(oneQuest.Answer2);
            copyQuest.Add(oneQuest.Answer3);
            copyQuest.Add(oneQuest.Answer4);

            while (n > 1)
            {
                n--;
                int    k     = rng.Next(n + 1);
                string value = copyQuest[k];
                copyQuest[k] = copyQuest[n];
                copyQuest[n] = value;
            }

            copyQuest.Add(oneQuest.Question);//в самом конце записываем текущий вопрос


            return(new OneQuestionAndAnswers(copyQuest[4], copyQuest[0],
                                             copyQuest[1], copyQuest[2], copyQuest[3], oneQuest.Answer1));
        }
コード例 #2
0
ファイル: ListQuestions.cs プロジェクト: Bismila/Millioner
 public void EditQuest(int index, OneQuestionAndAnswers q)
 {
     if (index < 0 || index >= listQA.Count)
     {
         return;
     }
     listQA.Remove(listQA[index]);
     listQA.Insert(Convert.ToInt32(CurIndexOfQuest), q);
 }
コード例 #3
0
ファイル: ListQuestions.cs プロジェクト: Bismila/Millioner
        public List <OneQuestionAndAnswers> ShuffleQuest(List <OneQuestionAndAnswers> allList)
        {
            List <OneQuestionAndAnswers> copyList = new List <OneQuestionAndAnswers>();

            copyList = allList;
            int n = allList.Count;

            while (n > 1)
            {
                n--;
                int k = rng.Next(n + 1);

                OneQuestionAndAnswers value = copyList[k];
                copyList[k] = copyList[n];
                copyList[n] = value;
            }
            return(copyList);
        }
コード例 #4
0
ファイル: ListQuestions.cs プロジェクト: Bismila/Millioner
 public void AddQuest(OneQuestionAndAnswers q)
 {
     this.listQA.Add(q);
     index++;
 }