public void CanParseTermsFromGOOD2TermExpression()
 {
     BasicTasks doSomething = new BasicTasks();
     doSomething.DelineateTerms("8+2");
     Assert.AreEqual(doSomething.firstNumb, 8);
     Assert.AreEqual(doSomething.secNumb, 2);
     Assert.AreEqual(doSomething.OurDelimeter, '+');
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            int counter = 0;
            var propeller = true;
            BasicTasks basicOperation = new BasicTasks();

            while (propeller) {

                string prompt = "[" + counter + "]" + "> ";

                // Take the user's input expression and save it to a variable
                Console.Write(prompt);
                string expression = Console.ReadLine();

                switch (expression)
                {
                    //Handling one keyword for exiting application
                    case "quit":
                        Console.WriteLine("See ya!");
                        Environment.Exit(1);
                        return;

                    // Handling another keyword for exiting the application
                    case "exit":
                        Console.WriteLine("See ya!");
                        Environment.Exit(1);
                        return;

                    // Handling the user entering "last" command
                    case "last":
                        Console.WriteLine(Stack.LastAnswer);
                        break;

                    // Handling the user entering "lastq" command
                    case "lastq":
                        Console.WriteLine(Stack.LastCommand);
                        break;

                    // Handling the user entering an expression to be evaluated
                    default:

                        // Increment counter with each go round
                        // counter = counter + 1;

                        // Stashing this away so it's ready if user enters "lastq" command
                        if (expression != "lastq" || expression != "last")
                        {
                            Stack.LastCommand = expression;
                        }

                        // Going to find our delimeter
                        basicOperation.DelineateTerms(expression);
                        Evaluate evaluating = new Evaluate(basicOperation);

                        //Stack MainStack = new Stack();

                        // Here we determine whether to send this on for calculation or constant setting
                        switch (basicOperation.OurDelimeter)
                        {
                            // Will get set as a constant
                            case '=':
                                basicOperation.calcStack.SettingConstant(basicOperation.ifChar, basicOperation.secNumb);
                                //Console.WriteLine("the expression " + expression + " has been added to the dictionary");
                                break;

                            default:
                                evaluating.EvaluateThis(expression);

                                // Increment counter with each go round
                                counter = counter + 1;
                                Console.WriteLine("= " + Computations.Answer);
                                break;
                        }
                        break;
                }
            }
        }
Beispiel #3
0
 public Evaluate(BasicTasks _task)
 {
     doMath = _task;
 }
Beispiel #4
0
 public Evaluate()
 {
     doMath = new BasicTasks();
 }
 public void ThrowsErrorForIncorrectExpression()
 {
     BasicTasks doSomething = new BasicTasks();
     doSomething.DelineateTerms("8+");
 }