Ejemplo n.º 1
0
 public void DeleteShowedQuestion(List <QuestionAndAnwers> questionAndAnwersofCat, string question)
 {
     for (int i = 0; i < questionAndAnwersofCat.Count; i++)
     {
         QuestionAndAnwers item = questionAndAnwersofCat[i];
         if (item.Question == question)
         {
             questionAndAnwersofCat.Remove(item);
             break;
         }
     }
 }
Ejemplo n.º 2
0
        public List <List <QuestionAndAnwers> > OpenQuestionFromEachCategory(List <QuestionAndAnwers> questionAndAnwersOfSingleCat, List <Category> categories, List <List <QuestionAndAnwers> > listofListsWithQuestionsFromEachCategory)
        {
            foreach (var item in categories)
            {
                string            path = $"{item.Name.ToLower()}.txt";
                StreamReader      sr   = null;
                string            lineOfText;
                int               counterLine = 1;
                QuestionAndAnwers question    = new QuestionAndAnwers();
                sr = File.OpenText(path);
                while ((lineOfText = sr.ReadLine()) != null)
                {
                    switch (counterLine)
                    {
                    case 1:
                        question.Question = lineOfText;
                        counterLine++;
                        break;

                    case 2:
                        question.GoodAnswer = lineOfText;
                        counterLine++;
                        break;

                    case 3:
                        question.BadAnswer = lineOfText;
                        counterLine++;
                        break;

                    case 4:
                        question.BadAnswer1 = lineOfText;
                        counterLine++;
                        break;

                    case 5:
                        question.BadAnswer2 = lineOfText;
                        counterLine++;
                        break;

                    default:
                        questionAndAnwersOfSingleCat.Add(question);
                        counterLine = 1;
                        question    = new QuestionAndAnwers();
                        break;
                    }
                }
                listofListsWithQuestionsFromEachCategory.Add(questionAndAnwersOfSingleCat);
                questionAndAnwersOfSingleCat = new List <QuestionAndAnwers>();
                sr.Close();
            }
            return(listofListsWithQuestionsFromEachCategory);
        }