static void Main(string[] args) { Console.WriteLine("What is your name?"); string userName = Console.ReadLine(); Parse p = new Parse(); Evaluate e = new Evaluate(); bool run = true; while (run) { Console.WriteLine(userName + " Define your mathematical operation"); string input = Console.ReadLine(); if (input.ToUpper() == "LASTQ") { Console.WriteLine(e.lastExpression()); run = false; break; } string oper = p.getOperator(input); int num1 = p.getNumberOne(input); int num2 = p.getNumberTwo(input); int answer = e.ExecuteMethod(num1, num2, oper); Console.WriteLine("The answer to your operation is: " + answer); } Console.WriteLine("Press any key to exit"); Console.ReadLine(); }
public void EvaluateTestEnsureICanSubtract() { Evaluate e = new Evaluate(); Parse p = new Parse(); string input = "2 - 2"; int num1 = p.getNumberOne(input); int num2 = p.getNumberTwo(input); string oper = p.getOperator(input); int expected = 0; Assert.AreEqual(expected, e.ExecuteMethod(num1, num2, oper)); }
public void CommandEnsureICanGetReturnFromLastQCommand() { Parse p = new Parse(); Evaluate e = new Evaluate(); string input = "2 + 2"; int num1 = p.getNumberOne(input); int num2 = p.getNumberTwo(input); string oper = p.getOperator(input); int answer = e.ExecuteMethod(num1, num2, oper); string expected = "2 + 2"; string actual = e.lastExpression(); Assert.AreEqual(expected, actual); }
public void ParseEnsureICanGetAdditionOperator() { Parse p = new Parse(); string input = "2 + 2"; Assert.AreEqual("+", p.getOperator(input)); }
public void ParseEnsureICanCaptureBadInputNegativeSpaceNumber() { Parse p = new Parse(); string input = "2+- 3"; p.getOperator(input); }
public void ParseEnsureICanCaptureBadInputDoubleOperator() { Parse p = new Parse(); string input = "2 ++ 2"; p.getOperator(input); }