예제 #1
0
파일: Form1.cs 프로젝트: Galacticus3/Tasks
 private void button19_Click(object sender, EventArgs e)
 {
     textBox1.Text = "";
     textBox1.Tag  = "";
     znak          = znaky.pusto;
     rez           = 0;
     n1            = 0;
     n2            = 0;
     igorsCalculator.resetData();
     dilenzero = false;
     flag      = false;
 }
예제 #2
0
파일: Form1.cs 프로젝트: Galacticus3/Tasks
 //кнопка /
 private void button15_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "" && dilenzero == false)
     {
         Actionn();
         znak = znaky.dilen;
         flag = true;
         n1   = 0;
     }
     else
     {
         return;
     }
 }
예제 #3
0
        void Actionn()
        {
            n2 = Convert.ToDouble(textBox1.Text);

            switch (znak)
            {
                case znaky.pusto:
                    {
                        rez = Convert.ToDouble(textBox1.Text);
                        break;
                    }
                case znaky.plus:
                    {
                        if (n1 != 0) n2 = n1;
                        //rez = rez + n2;
                        rez = igorsCalculator.add(rez, n2);
                        textBox1.Text = Convert.ToString(rez);
                        n1 = n2;
                        break;
                    }
                case znaky.minus:
                    {
                        if (n1 != 0) n2 = n1;
                        //rez = rez - n2;
                        rez = igorsCalculator.sub(rez, n2);
                        textBox1.Text = Convert.ToString(rez);
                        n1 = n2;
                        break;
                    }

                case znaky.mnozh:
                    {
                        if (n1 != 0) n2 = n1;
                        //rez = rez * n2;
                        rez = igorsCalculator.mul(rez, n2);
                        textBox1.Text = Convert.ToString(rez);
                        n1 = n2;
                        break;
                    }
                case znaky.dilen:
                    {
                       /* if (Convert.ToDouble(textBox1.Text) == 0)
                        {
                            textBox1.Text = "На ноль нельзя!";
                            znak = znaky.pusto;
                            dilenzero = true;
                            flag = false;
                        }
                        else
                        {
                            if (n1 != 0) n2 = n1;
                            //rez = rez / n2;
                            rez = igorsCalculator.div(rez, n2);
                            //try {  }
                            //catch (DivideByZeroException e) {  }
                            textBox1.Text = Convert.ToString(rez); //Convert.ToDouble(textBox1.Text));
                            n1 = n2;
                        }*/
                        try
                        {
                            if (n1 != 0) n2 = n1;
                            rez = igorsCalculator.div(rez, n2);
                            textBox1.Text = Convert.ToString(rez); //Convert.ToDouble(textBox1.Text));
                            n1 = n2;
                        }
                        catch (DivideByZeroException)
                        {
                            znak = znaky.pusto;
                            flag = false;
                            MessageBox.Show("На ноль нельзя!");
                        }
                        break;
                    }
            }
        }
예제 #4
0
 private void button19_Click(object sender, EventArgs e)
 {
     textBox1.Text = "";
     textBox1.Tag = "";
     znak = znaky.pusto;
     rez = 0;
     n1 = 0;
     n2 = 0;
     igorsCalculator.resetData();
     dilenzero = false;
     flag = false;
 }
예제 #5
0
 //кнопка /
 private void button15_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "" && dilenzero == false)
     {
         Actionn();
         znak = znaky.dilen;
         flag = true;
         n1 = 0;
     }
     else
     { return; }
 }
예제 #6
0
파일: Form1.cs 프로젝트: Galacticus3/TasksS
        void Actionn()
        {
            n2 = Convert.ToDouble(textBox1.Text);

            switch (znak)
            {
                case znaky.pusto:
                    {
                        rez = Convert.ToDouble(textBox1.Text);
                        break;
                    }
                case znaky.plus:
                    {
                        if (n1 != 0) n2 = n1;
                        rez = rez + n2;
                        textBox1.Text = Convert.ToString(rez);
                        n1 = n2;
                        break;
                    }
                case znaky.minus:
                    {
                        if (n1 != 0) n2 = n1;
                        rez = rez - n2;
                        textBox1.Text = Convert.ToString(rez);
                        n1 = n2;
                        break;
                    }

                case znaky.mnozh:
                    {
                        if (n1 != 0) n2 = n1;
                        rez = rez * n2;
                        textBox1.Text = Convert.ToString(rez);
                        n1 = n2;
                        break;
                    }
                case znaky.dilen:
                    {
                        if (Convert.ToDouble(textBox1.Text) == 0)
                        {
                            textBox1.Text = "На ноль нельзя!";
                            znak = znaky.pusto;
                            dilenzero = true;
                            flag = false;
                        }
                        else
                        {
                            if (n1 != 0) n2 = n1;
                            rez = rez / n2;
                            textBox1.Text = Convert.ToString(rez); //Convert.ToDouble(textBox1.Text));
                            n1 = n2;
                        }
                        break;
                    }
            }
        }
예제 #7
0
파일: Form1.cs 프로젝트: Galacticus3/Tasks
        void Actionn()
        {
            n2 = Convert.ToDouble(textBox1.Text);

            switch (znak)
            {
            case znaky.pusto:
            {
                rez = Convert.ToDouble(textBox1.Text);
                break;
            }

            case znaky.plus:
            {
                if (n1 != 0)
                {
                    n2 = n1;
                }
                //rez = rez + n2;
                rez           = igorsCalculator.add(rez, n2);
                textBox1.Text = Convert.ToString(rez);
                n1            = n2;
                break;
            }

            case znaky.minus:
            {
                if (n1 != 0)
                {
                    n2 = n1;
                }
                //rez = rez - n2;
                rez           = igorsCalculator.sub(rez, n2);
                textBox1.Text = Convert.ToString(rez);
                n1            = n2;
                break;
            }

            case znaky.mnozh:
            {
                if (n1 != 0)
                {
                    n2 = n1;
                }
                //rez = rez * n2;
                rez           = igorsCalculator.mul(rez, n2);
                textBox1.Text = Convert.ToString(rez);
                n1            = n2;
                break;
            }

            case znaky.dilen:
            {
                /* if (Convert.ToDouble(textBox1.Text) == 0)
                 * {
                 *   textBox1.Text = "На ноль нельзя!";
                 *   znak = znaky.pusto;
                 *   dilenzero = true;
                 *   flag = false;
                 * }
                 * else
                 * {
                 *   if (n1 != 0) n2 = n1;
                 *   //rez = rez / n2;
                 *   rez = igorsCalculator.div(rez, n2);
                 *   //try {  }
                 *   //catch (DivideByZeroException e) {  }
                 *   textBox1.Text = Convert.ToString(rez); //Convert.ToDouble(textBox1.Text));
                 *   n1 = n2;
                 * }*/
                try
                {
                    if (n1 != 0)
                    {
                        n2 = n1;
                    }
                    rez           = igorsCalculator.div(rez, n2);
                    textBox1.Text = Convert.ToString(rez);         //Convert.ToDouble(textBox1.Text));
                    n1            = n2;
                }
                catch (DivideByZeroException)
                {
                    znak = znaky.pusto;
                    flag = false;
                    MessageBox.Show("На ноль нельзя!");
                }
                break;
            }
            }
        }
예제 #8
0
 // Kонструктор. Tут, думаю, нічого не треба міняти
 public IgorsCalculator()
 {
     latestResult = null;
     latestOperand = null;
     latestOperation = znaky.pusto;
 }
예제 #9
0
 // обнулити дані "С".
 public void resetData()
 {
     latestResult = null;
     latestOperand = null;
     latestOperation = znaky.pusto;
 }
예제 #10
0
 // обнулити дані "С".
 public void resetData()
 {
     latestResult    = null;
     latestOperand   = null;
     latestOperation = znaky.pusto;
 }
예제 #11
0
 // Kонструктор. Tут, думаю, нічого не треба міняти
 public IgorsCalculator()
 {
     latestResult    = null;
     latestOperand   = null;
     latestOperation = znaky.pusto;
 }