Exemple #1
0
        private void EqualButton_Click(object sender, EventArgs e)
        {
            if (isOperation)
            {
                secondV = Convert.ToDouble(textBox1.Text);
            }
            else
            {
                label2.Text = textBox1.Text;
                isEqual     = true;
                return;
            }

            label2.Text = c.FirstValue + c.Operation + Convert.ToString(secondV);
            isEqual     = true;
            isOperation = false;

            switch (c.Operation)
            {
            case "+":
                textBox1.Text = Convert.ToString(c.Plus(secondV));
                break;

            case "-":
                textBox1.Text = Convert.ToString(c.Minus(secondV));
                break;

            case "*":
                textBox1.Text = Convert.ToString(c.Multiply(secondV));
                break;

            case "/":

                if (secondV != 0)
                {
                    textBox1.Text = Convert.ToString(c.Divide(secondV));
                }
                else
                {
                    MessageBox.Show("На ноль делить нельзя");
                    isEqual = false;
                    MainText();
                    SecondaryText();
                    c = new Calculate();
                }
                break;
            }
        }