private void AddOperatorElement(Element element)
        {
            float builtNumber = NumberBuilder.BuildNumber();

            CalculatorModel.AddNumberToCalculation(builtNumber);
            CalculatorModel.AddOperatorToCalculation(ElementEvaluator.EvaluateElement(element));
            ShowNumber(builtNumber);
            NumberBuilder.NewNumber();
        }
 private void AddNumericalElement(Element element)
 {
     if (NumberBuilder.BuildNumber() == CalculatorModel.MostRecentResult)
     {
         NumberBuilder.NewNumber();
     }
     NumberBuilder.Append(ElementEvaluator.EvaluateElement(element));
     ShowNumber(NumberBuilder.BuildNumber());
 }
        public static void Append(string addedCharacters)
        {
            if (ElementEvaluator.IsOperator(addedCharacters))
            {
                return;
            }
            if (ElementEvaluator.EvaluateValue(addedCharacters) == Element.DECIMAL && NumberAsString.Contains(ElementEvaluator.EvaluateElement(Element.DECIMAL)))
            {
                return;
            }

            float  multiplication      = 1;
            string tempAddedCharacters = addedCharacters;

            for (int i = 0; i < tempAddedCharacters.Length; i++)
            {
                if (tempAddedCharacters.Contains(ElementEvaluator.EvaluateElement(Element.SIGN_CHANGE)))
                {
                    multiplication *= -1;
                    int foundIndex  = tempAddedCharacters.IndexOf(ElementEvaluator.EvaluateElement(Element.SIGN_CHANGE));
                    int foundLength = ElementEvaluator.EvaluateElement(Element.SIGN_CHANGE).Length;
                    tempAddedCharacters = tempAddedCharacters.Remove(foundIndex, foundLength);
                }
            }
            NumberAsString += tempAddedCharacters;
            string temp = NumberAsString;

            NumberAsString = (multiplication * Number).ToString();
            if (temp != NumberAsString)
            {
                if (NumberAsString.Contains("-"))
                {
                    string signChanged = temp.Insert(0, "-");
                    if (signChanged != NumberAsString)
                    {
                        NumberAsString += ",";
                    }
                }
                else if (temp.Contains("-"))
                {
                    string tempNumberAsString = NumberAsString.Insert(0, "-");
                    if (temp != tempNumberAsString)
                    {
                        NumberAsString += ",";
                    }
                }
                else
                {
                    NumberAsString += ",";
                }
            }
        }
        private static float Calculate(List <float> numbers, List <string> operators)
        {
            List <float> tempNumbers     = new List <float>(numbers);
            float        currentValue    = tempNumbers[0];
            string       currentOperator = "";

            tempNumbers.RemoveAt(0);
            for (int i = 0; i < operators.Count && tempNumbers.Count > 0; i++)
            {
                currentOperator = operators[i];
                switch (ElementEvaluator.EvaluateValue(operators[i]))
                {
                case Element.PLUS:
                    currentValue += tempNumbers.First();
                    break;

                case Element.MINUS:
                    currentValue -= tempNumbers.First();
                    break;

                case Element.MULTIPLICATION:
                    currentValue *= tempNumbers.First();
                    break;

                case Element.DIVISION:
                    currentValue /= tempNumbers.First();
                    break;

                default:
                    currentValue = DEFAULT_START_VALUE;
                    break;
                }
                tempNumbers.Remove(tempNumbers.First());
            }
            return(currentValue);
        }