コード例 #1
0
ファイル: Calculator.cs プロジェクト: bobland1/CalculatorApp
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            try
            {
                var input = txtMessage.Text;

                var equation = EquationHelper.RemoveWhitespace(input);

                if (EquationValidator.IsEquationValid(equation))
                {
                    var result = EquationTreeGenerator.Calculation(equation).getValue();
                    txtMessage.Text = result.ToString();

                    lblMessage.Text = "Enter another equation";
                }
                else
                {
                    lblMessage.Text = "Invalid Equation! Please try again";
                }
            }
            catch (InvalidEquationException ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
コード例 #2
0
 public EquationNode(string leftSide, string rightSide, IOperator Operator)
 {
     Left          = EquationTreeGenerator.Calculation(leftSide);
     Right         = EquationTreeGenerator.Calculation(rightSide);
     this.Operator = Operator;
 }