}// end submitButton_Click /// <summary> /// Converts the input string to all lowercase letters and removes all spaces. Then checks if /// the variables being used have values in their textboxes and that they are correct values. /// If not, the user is alerted. The variables in the string are replaced with their values. /// Then, the input string is them converted to postfix format and evaluated. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void submitButton_Click(object sender, EventArgs e) { string infix = evaluationBox.Text; // Get the string from the evaluation textbox System.Diagnostics.Debug.WriteLine(infix); infix = infix.ToLower(); // Converts all upper case characters in the string to lower case infix = infix.Replace(" ", string.Empty); // Remove all spaces from the string System.Diagnostics.Debug.WriteLine(infix); if (variableCheck(ref infix)) { System.Diagnostics.Debug.WriteLine(infix); // Replace all variables with their associated values infix = replaceVariablesWithValues(infix); System.Diagnostics.Debug.WriteLine(infix); //CommandFactory factory = new BasicFactory(); CommandFactory factory = new OptimizedFactory(); // Parse the user's equation from infix into postfix format Parser parser = new Parser(); List<Command> postfix = parser.infixToPostfix(infix, factory); System.Diagnostics.Debug.WriteLine(infix); // Evaluate the postfix format equation Evaluator evaluator = new Postfix(); int result = evaluator.evaluatePostfix(postfix); lblEqual.Visible = true; lblResult.Text = result.ToString(); }// end if }// end submitButton_Click