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; } }
public EquationNode(string leftSide, string rightSide, IOperator Operator) { Left = EquationTreeGenerator.Calculation(leftSide); Right = EquationTreeGenerator.Calculation(rightSide); this.Operator = Operator; }