public void MathRouter(int firstInt, char operatorChar, int secondInt) { if (operatorChar == '+') { AddNumber addnumber = new AddNumber(); addnumber.AddStuff(firstInt, secondInt); } else if (operatorChar == '-') { SubtractNumber subtractnumber = new SubtractNumber(); subtractnumber.SubtractStuff(firstInt, secondInt); } else if (operatorChar == '*') { MultiplyNumber multiplynumber = new MultiplyNumber(); multiplynumber.MultiplyStuff(firstInt, secondInt); } else if (operatorChar == '/') { DivideNumber dividenumber = new DivideNumber(); dividenumber.DivideStuff(firstInt, secondInt); } else if (operatorChar == '%') { ModulusizeNumber modulusizeNumber = new ModulusizeNumber(); modulusizeNumber.ModulusizeStuff(firstInt, secondInt); } }
public void EnsureFourModulusTwo() { ModulusizeNumber modulusizenumber = new ModulusizeNumber(); int expectedResult = 0; int actualResult = modulusizenumber.ModulusizeStuff(4, 2); Assert.AreEqual(expectedResult, actualResult); }
//public void ConvertString(string a, string op, string b) //{ // int firstNumberInEquation = Convert.ToInt32(a); // char operatorInEquation = Convert.ToChar(op); // int secondNumberInEquation = Convert.ToInt32(b); // MathRouter(firstNumberInEquation, operatorInEquation, secondNumberInEquation); //} public int MathRouter(string firstInt, string operatorChar, string secondInt) { int firstNumberInEquation = Convert.ToInt32(firstInt); char operatorInEquation = Convert.ToChar(operatorChar); int secondNumberInEquation = Convert.ToInt32(secondInt); int result = 0; if (operatorInEquation == '+') { AddNumber addnumber = new AddNumber(); result = addnumber.AddStuff(firstNumberInEquation, secondNumberInEquation); } else if (operatorInEquation == '-') { SubtractNumber subtractnumber = new SubtractNumber(); result = subtractnumber.SubtractStuff(firstNumberInEquation, secondNumberInEquation); } else if (operatorInEquation == '*') { MultiplyNumber multiplynumber = new MultiplyNumber(); result = multiplynumber.MultiplyStuff(firstNumberInEquation, secondNumberInEquation); } else if (operatorInEquation == '/') { DivideNumber dividenumber = new DivideNumber(); result = dividenumber.DivideStuff(firstNumberInEquation, secondNumberInEquation); } else if (operatorInEquation == '%') { ModulusizeNumber modulusizeNumber = new ModulusizeNumber(); result = modulusizeNumber.ModulusizeStuff(firstNumberInEquation, secondNumberInEquation); } // Set the last answer field LastAnswer(result); // Set the last question //LastQuestion($"{firstInt} {operatorChar} {secondInt}"); DisplayAnswer(result, $"{firstInt} {operatorChar} {secondInt}"); return(result); }