Esempio n. 1
0
        //order: 0 for RND, 1 for FTL, 2 LTF
        public void Get1FC(PharmacyForm PH, int order)
        {
            FlashCard c = new FlashCard();

            if (order == 0)
            {
                c = getRandomFC();
            }
            else
            {
                c = (FlashCard)cards[index++];
            }
            if (index == cards.Count)
            {
                index = 0;
            }
            //Question and answer must contain one word

            Regex rx = new Regex(@"\b([a-zA-Z]+)\b");

            //System.Threading.Thread.Sleep(200);
            if (rx.IsMatch(c.Question) && rx.IsMatch(c.Answer))
            {
                PH.questionlabel.Text = c.Question;

                PH.rightAnswer = c.Answer;
            }
        }
Esempio n. 2
0
 private static void TwoLineFCMethod(Deck deck, ref string line, ref int i, ref FlashCard card)
 {
     if (i++ % 2 == 0)//is even numbered line, meaning it is a question field
     {
         //Console.WriteLine(line);
         card.Question = line;
     }
     else
     {
         //If reversible, add another reversed card.
         if (line.Contains("rev;"))
         {
             line        = line.Remove(0, 4);
             card.Answer = line;
             deck.Add(card);
             var temp = new FlashCard();
             temp.Question = line;
             temp.Answer   = card.Question;
             deck.Add(temp);
             card = new FlashCard();
         }
         else
         {
             card.Answer = line;
             deck.Add(card);
             card = new FlashCard();
         }
     }
 }
Esempio n. 3
0
 private static void OneLineFCMethod(Deck deck, ref string line, ref int i, ref FlashCard card)
 {
     card.Question = line.Split(' ', '\t', ';')[0];
     card.Answer   = line.Split(' ').Length > 1 ? line.Split(' ')[1] : line.Split(' ')[0];
     deck.Add(card);
     card = new FlashCard();
 }
Esempio n. 4
0
        //Add fc to deck
        private static void ParseFC(Deck deck, StreamReader sr, int method)
        {
            String    line;
            int       i    = 0;
            FlashCard card = new FlashCard();

            while ((line = sr.ReadLine()) != null)
            {
                if (method == 0)
                {
                    TwoLineFCMethod(deck, ref line, ref i, ref card);
                }
                else if (method == 1)
                {
                    OneLineFCMethod(deck, ref line, ref i, ref card);
                }
            }
        }
Esempio n. 5
0
        public static void SaveRandomizedCards(string filename)
        {
            FileStream fs   = new FileStream(filename, FileMode.Open);
            Deck       deck = new Deck("CSharp");

            using (StreamReader sr = new StreamReader(fs))
            {
                String    line;
                int       i    = 0;
                FlashCard card = new FlashCard();
                while ((line = sr.ReadLine()) != null)
                {
                    if (i++ % 2 == 0)//is even numbered line, meaning it is a question field
                    {
                        //Console.WriteLine(line);
                        card.Question = line;
                    }
                    else
                    {
                        //If reversible, add another reversed card.
                        if (line.Contains("rev;"))
                        {
                            line        = line.Remove(0, 4);
                            card.Answer = line;
                            deck.Add(card);
                            var temp = new FlashCard();
                            temp.Question = line;
                            temp.Answer   = card.Question;
                            deck.Add(temp);
                            card = new FlashCard();
                        }
                        else
                        {
                            card.Answer = line;
                            deck.Add(card);
                            card = new FlashCard();
                        }
                    }
                }
            }
            deck.cards = deck.cards.Randomize();
            File.WriteAllLines(filename.Replace(".txt", "") + "random.txt", (string[])deck.cards.ToArray(typeof(string)));
        }
Esempio n. 6
0
 public void Add(FlashCard c)
 {
     cards.Add(c);
 }