public void ParseEnsureICanGetTheOperatorType() { Parse value = new Parse(); char actualChar = value.OperatorType("2/2"); char expectedChar = '/'; Assert.AreEqual(expectedChar, actualChar); }
public static int Calculation(string input) { Parse val = new Parse(); string[] inputParsed = val.Equation(input); char operation = val.OperatorType(input); int[] inputToInt = val.ValuesToInt(inputParsed); if (operation == '+') { return Add(inputToInt); } else if (operation == '-') { return Subtract(inputToInt); } else if (operation == '*') { return Multi(inputToInt); } else if (operation == '/') { return Divide(inputToInt); } else if (operation == '%') { return Modulo(inputToInt); } else { throw new InvalidOperationException("Error: Calculations must only use +, -, *, /, or %"); } }