Exemplo n.º 1
0
 private void ResetScore()
 {
     toolStripTextBoxScoreAmount.Text = "0";
     toolStripLabelSpeed.Text         = "1";
     progressBar.Value = 0;
     AnswertextBox.Clear();
     progressBar.Maximum = progressBar.Maximum;
 }
Exemplo n.º 2
0
        private void AnswertextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && SendAnswer == true)
            {
                Answer = AnswertextBox.Text.Trim();
                Answer = Answer.Replace(".", ",");

                IsCorrect = IsAnswerCorrect();
                double AmountScore = double.Parse(toolStripTextBoxScoreAmount.Text);
                int    speed       = int.Parse(toolStripLabelSpeed.Text);
                if (IsCorrect == true)
                {
                    AmountScore += addbal;
                    progressBar.Increment(-5);
                    if (AmountScore >= speed * 10 && speed != MAX_Speed)
                    {
                        speed++;
                        toolStripLabelSpeed.Text = speed.ToString();
                        progressBar.Maximum     -= 3;
                    }
                    ShowStatusMessage($"Правильно! +{addbal}");
                    toolStripTextBoxScoreAmount.Text = AmountScore.ToString();
                    SuccessVoice();
                }
                else if (IsCorrect == false)
                {
                    if (AmountScore > 0)
                    {
                        AmountScore -= 0.5;
                        toolStripTextBoxScoreAmount.Text = AmountScore.ToString();
                        FailVoice();
                    }
                }
                AnswertextBox.Clear();
                OperationSelectForm();
                SelectDiapazon();
            }
        }
Exemplo n.º 3
0
        private bool IsAnswerCorrect()
        {
            try
            {
                double res        = 0;
                double num1       = double.Parse(Num1.Text);
                double num2       = double.Parse(Num2.Text);
                double answer_num = double.Parse(Answer);
                switch (operation)
                {
                case Operation.Add: res = num1 + num2; break;

                case Operation.Difference: res = num1 - num2; break;

                case Operation.Multiplication: res = num1 * num2; addbal *= 2; break;

                case Operation.Division: res = num1 / num2; res = Math.Round(res, 2); addbal *= 2.5; break;
                }
                if (res == answer_num)
                {
                    return(true);
                }
                else
                {
                    ShowStatusMessage("Неправильно! Спробуй ще раз ");
                    return(false);
                }
            }
            catch
            {
                AnswertextBox.Clear();
                OperationSelectForm();
                SelectDiapazon();
                SelectTimeRegime();
                ShowStatusMessage("Ви ввели не число");
                return(false);
            }
        }