private void AddOperatorElement(Element element) { float builtNumber = NumberBuilder.BuildNumber(); CalculatorModel.AddNumberToCalculation(builtNumber); CalculatorModel.AddOperatorToCalculation(ElementEvaluator.EvaluateElement(element)); ShowNumber(builtNumber); NumberBuilder.NewNumber(); }
public void ShowResult() { var resultValue = CalculatorModel.GetResult(); ShowNumber(resultValue); CalculatorModel.Clear(); NumberBuilder.NewNumber(); NumberBuilder.Append(resultValue.ToString()); }
private void AddNumericalElement(Element element) { if (NumberBuilder.BuildNumber() == CalculatorModel.MostRecentResult) { NumberBuilder.NewNumber(); } NumberBuilder.Append(ElementEvaluator.EvaluateElement(element)); ShowNumber(NumberBuilder.BuildNumber()); }
private void DoOperation() { float mostRecentNumber = CalculatorModel.MostRecentNumber; float builtNumber = NumberBuilder.BuildNumber(); CalculatorModel.AddNumberToCalculation(builtNumber); if (CalculatorModel.AmountOfNumbers == 1 && CalculatorModel.AmountOfOperators == 0) { CalculatorModel.AddOperatorToCalculation(CalculatorModel.MostRecentOperator); CalculatorModel.AddNumberToCalculation(mostRecentNumber); } NumberBuilder.NewNumber(); ShowResult(); }
private void ClearAllButtonClick(object sender, RoutedEventArgs e) { NumberBuilder.NewNumber(); CalculatorModel.Clear(); ShowNumber(CalculatorModel.DEFAULT_START_VALUE); }