Пример #1
0
 /// <summary>
 /// For multiplication read left to right, clear everything except the value which will
 /// be stored in the last position to allow for more operations if they exist.
 /// </summary>
 /// <param name="section"></param>
 private List<string> PerformMultiplicationAndDivision(List<string> section)
 {
     var complexSection = section.Where(x => !string.IsNullOrEmpty(x)).ToList();
     for (var x = 0; x < complexSection.Count; x++)
         x = PerformCoreCalculations(complexSection, x, "/", "*", false);
     return complexSection;
 }
Пример #2
0
 /// <summary>
 /// For addition and subtraction read right to left, clear everthing except the value which
 /// will be stored in the last postion to allow for more operation if they exist.
 /// </summary>
 /// <param name="section"></param>
 /// <returns></returns>
 private double PerformAdditionAndSubtration(List<string> section)
 {
     var simpleSection = section.Where(x => !string.IsNullOrEmpty(x)).ToList();
     for (var x = simpleSection.Count - 1; x >= 0; x--)
         x = PerformCoreCalculations(simpleSection, x, "-","+", true);
     return simpleSection.Where(x => !string.IsNullOrEmpty(x)).Sum(s => double.Parse(s));
 }