static void Main(string[] args) { // new counter for program Counter thisCounterInst = new Counter(); // boolean for running program and breaking out of while loop bool isRunning = true; // while bool = true, run this loop while (isRunning) { // writing the counter Console.Write("[" + thisCounterInst.CountValue + "]"); // accepting the input string input = Console.ReadLine(); // validating that syntax is right and not exiting loop ValidInputs validating = new ValidInputs(); bool ValidateResult = validating.BreakingLoop(input); // if not valid result, exit loop if (ValidateResult == false) { isRunning = false; break; } else { // other wise, valid result -- new Calculator instance Calculator CalculatorInstance = new Calculator(); if (input == "lastq" || input == " lastq") { // show the last question Console.WriteLine(LastQnA.LastQ); } else if (input == "last" || input == " last") { // show last answer Console.WriteLine(LastQnA.LastAns); } else { // new calculator instance and begin calculation int thisAnswer = CalculatorInstance.Calculate(input); Console.WriteLine(thisAnswer); } // increment counter thisCounterInst.CountValue = thisCounterInst.Count + 1; } } }
public void loop() { // gets input string input = Console.ReadLine(); // instance of validating input ValidInputs ValidateIt = new ValidInputs(); bool TestResult = ValidateIt.BreakingLoop(input); // tests input while (TestResult) { ExecuteFunc thisInstance = new ExecuteFunc(); thisInstance.Execute(input); loopIt NewOne = new loopIt(); } }
public void ValidInputRec4Regex() { string input = "3 + 4"; ValidInputs TestRegexPass = new ValidInputs(); bool answer = TestRegexPass.BreakingLoop(input); Assert.AreEqual(true, answer); }
public void QuitProcessed() { ValidInputs TestQuit = new ValidInputs(); bool answer = TestQuit.BreakingLoop("quit"); Assert.AreEqual(false, answer); }