Exemplo n.º 1
0
        public void CorrectPowerOfTwoResult(int a, int expected)
        {
            var result = Calculators.PowerOfTwo(a);

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 2
0
        //Print Button
        private void BEqual_Click(object sender, RoutedEventArgs e)
        {
            if (printed == true)
            {
            }                        // if has been printed dont print again

            else if (operation == "+")
            {
                result         = (Calculators.Add(number1, number2));
                Resultbox.Text = result.ToString();
                FullText.Text += $" {number2} = {result}";
            }
            else if (operation == "-")
            {
                result         = (Calculators.Subtract(number1, number2));
                Resultbox.Text = result.ToString();
                FullText.Text += $" {number2} = {result}";
            }
            else if (operation == "*")
            {
                result         = (Calculators.Multiply(number1, number2));
                Resultbox.Text = result.ToString();
                FullText.Text += $" {number2} = {result}";
            }
            else if (operation == "/")
            {
                if (number2 == 0)
                {
                    Resultbox.Text = "Cannot divide by 0"; //this way you are ready to add the second number
                }
                else
                {
                    result         = (Calculators.Divide(number1, number2));
                    Resultbox.Text = result.ToString();
                    FullText.Text += $" {number2} = {result}";
                }
            }
            else if (operation == "%")
            {
                result         = (Calculators.Modulus(number1, number2));
                Resultbox.Text = result.ToString();
                FullText.Text += $" {number2} = {result}";
            }
            else if (operation == "^")
            {
                result         = (Calculators.PowerOf(number1, number2));
                Resultbox.Text = result.ToString();
                FullText.Text += $" {number2} = {result}";
            }
            else if (operation == "^ 2")
            {
                result         = Calculators.PowerOfTwo(number1);
                Resultbox.Text = result.ToString();
                FullText.Text += $" = {result}";
            }
            else if (operation == "sqrt(0)")
            {
                result         = Calculators.Root(number2);
                Resultbox.Text = $"sqrt({number2}) = {result}";
                FullText.Text  = $"sqrt({number2}) = {result}";
            }

            printed = true;
        }