private void EquationButtonHandler(string expression) { if (!ValidateStr(mainDisplay) && !ValidateStr(secondNum)) { if (expressionQueue == false) { secondNum = mainDisplay; UpdateTextBoxes(firstNum, secondNum, expression); } else { string temp = expression; expression = Equations.GetQueueExpression(); secondNum = mainDisplay; UpdateTextBoxes(firstNum, secondNum, expression); Equations.SetExpression(temp); //expressionQueue = false; } } else if (!ValidateStr(mainDisplay) && ValidateStr(secondNum)) { firstNum = mainDisplay; txtBox_History.Text = Equations.Builder(firstNum, expression); if (ValidateStr(secondNum)) { secondNum = mainDisplay; } mainDisplay = ""; Equations.SetExpression(expression); expressionQueue = true; } else if (ValidateStr(mainDisplay)) { Equations.SetExpression(expression); expressionQueue = true; } //if (numSaved == false) //{ // if (ValidateStr(firstNum)) firstNum = mainDisplay; // txtBox_History.Text = Equations.Builder(firstNum, expression); // numSaved = true; // mainDisplay = ""; //} //else //{ // if (!ValidateStr(mainDisplay)) // { // secondNum = mainDisplay; // txtBox_History.Text = Equations.HistoryBuilder(firstNum, secondNum, expression); // firstNum = txtBox_Equation.Text = Equations.Builder(firstNum, secondNum, expression); // mainDisplay = ""; // } //} }
private void btn_Equals_Click(object sender, EventArgs e) { string lastExpression = expressionQueue == true?Equations.GetQueueExpression() : Equations.GetExpression(); if (!ValidateStr(firstNum) && ValidateStr(secondNum)) { secondNum = mainDisplay; } if (ValidateStr(firstNum)) { firstNum = mainDisplay; } if (!ValidateStr(firstNum) && !ValidateStr(secondNum) && !ValidateStr(lastExpression)) { switch (lastExpression) { case "addition": if (!ValidateStr(mainDisplay)) { secondNum = mainDisplay; } UpdateTextBoxes(firstNum, secondNum, "addition"); break; case "subtraction": if (!ValidateStr(mainDisplay)) { secondNum = mainDisplay; } UpdateTextBoxes(firstNum, secondNum, "subtraction"); break; case "multiplication": if (!ValidateStr(mainDisplay)) { secondNum = mainDisplay; } UpdateTextBoxes(firstNum, secondNum, "multiplication"); break; case "division": if (!ValidateStr(mainDisplay)) { secondNum = mainDisplay; } UpdateTextBoxes(firstNum, secondNum, "division"); break; } } else if (!string.IsNullOrEmpty(firstNum) && string.IsNullOrEmpty(secondNum)) { txtBox_History.Text = firstNum + " = "; } }
public Calculator() { variables = 0; eqSystem = null; solutions = null; }
public static double[] solutions; // Массив решений системы уравнений public Calculator(int inpVariables, Equations inpEquation) { variables = inpVariables; eqSystem = inpEquation; solutions = null; }
private void UpdateTextBoxes(string _firstNum, string _secondNum, string _expression) { txtBox_History.Text = Equations.HistoryBuilder(_firstNum, _secondNum, _expression); firstNum = txtBox_Equation.Text = Equations.Builder(_firstNum, _secondNum, _expression); mainDisplay = ""; }