Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Test testNum = new Test();
            bool mardus;

            mardus = testNum.Testn(Convert.ToInt16(ranAmount.Text));
            int         gCD;
            MardusClass myClass = new MardusClass();

            if (mardus == true)
            {
                int[] list = myClass.getRandom(Convert.ToInt16(ranAmount.Text));
                Answers.Clear();
                int checkSpace;
                for (int i = 0; i < list.Length; i++)
                {
                    Answers.AppendText(Convert.ToString(list[i] + " "));
                    checkSpace = i % 5;
                    if (checkSpace == 0)
                    {
                        Answers.AppendText("\n");
                    }
                }



                stat tstNums = new stat();

                gCD = tstNums.GCD(list);
                MessageBox.Show(Convert.ToString("The greatest CD is: " + gCD));
            }
            else
            {
                MessageBox.Show("Please make sure that the number that was entered is betwwen 5 and 20");
            }
        }
Example #2
0
 /// <summary>
 /// Clears the AnswerBox if the user uses TestMySelf or Challenge Mode again and adds the Question + CorrectAnswers as a title
 /// </summary>
 private void ResetAnswerBox()
 {
     Answers.Text = "";
     Answers.AppendText("Question" + "        " + "CorrectAnswers");
 }
Example #3
0
        /// <summary>
        /// Checks the answers to the question and showing the user their results
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AnswerBox_KeyDown(object sender, KeyEventArgs e)
        {
            Word = AnswerBox.Text;
            int CardIndex   = TempDecks[ChosenFileIndex].GetCardIndex();
            int CardsLength = TempDecks[ChosenFileIndex].GetCardsLength();

            bool[] Correct = new bool[CardsLength - 1];
            int    i       = 0;

            //If I press enter then it would get the word from the textbox
            if (e.KeyCode == Keys.Enter)
            {
                if (Word.ToLower() == TempDecks[ChosenFileIndex].GetCard(CardIndex).GetAnswer().ToLower())
                {
                    Correct[i] = true;
                    Score     += 1;
                }
                else
                {
                    Correct[i] = false;
                }
                //Resetting the Timer
                X                = 0;
                Y                = 128;
                counter          = 15;
                label1.ForeColor = Color.FromArgb(X, Y, Z);
                label1.Text      = counter.ToString();

                //Adds the Question and checks the box if I got it right in the CheckBox
                string Question = TempDecks[ChosenFileIndex].GetCard(CardIndex).GetQuestion();
                string Answer   = TempDecks[ChosenFileIndex].GetCard(CardIndex).GetAnswer();
                string QnA      = string.Format("Q:{0}  A:{1,2}", Question, Answer);
                if (Correct[i] == true)
                {
                    Answers.SelectionColor = Color.Green;
                    Answers.AppendText("\r\n" + QnA);
                    Answers.ScrollToCaret();
                }
                else
                {
                    Answers.SelectionColor = Color.Red;
                    Answers.AppendText("\r\n" + QnA);
                    Answers.ScrollToCaret();
                }

                i += 1;

                //Checking whether the user got 50% or more
                if (TempDecks[ChosenFileIndex].GetCardIndex() == TempDecks[ChosenFileIndex].GetCardsLength() - 1)
                {
                    if (((double)Score / TempDecks[ChosenFileIndex].GetCardsLength()) * 100 >= 50)
                    {
                        QuestionLabel.ForeColor = Color.Green;
                    }
                    else
                    {
                        QuestionLabel.ForeColor = Color.Red;
                    }
                    QuestionLabel.Text = "YOU SCORED " + Score + " / " + TempDecks[ChosenFileIndex].GetCardsLength();
                    Answers.Visible    = true;
                    TMSFinished        = true;
                    label1.Visible     = false;
                }
                // Changes to the next card when the user finishes answering the question
                else
                {
                    TempDecks[ChosenFileIndex].NextCard();

                    QuestionLabel.Text = TempDecks[ChosenFileIndex].GetCard
                                             (TempDecks[ChosenFileIndex].GetCardIndex())
                                         .GetQuestion();
                    IncreaseProgressBar();
                    ProgressBar.Value = ProgressBarValue;
                    ChangeCardPosition();
                }
            }
        }