예제 #1
0
 private static void AddNumberToQueue(string number)
 {
     if (!CheckForFails.isEmpty(number))
     {
         result.Enqueue(CreateCalcObject("Number", number));
     }
 }
예제 #2
0
        public void Calculate()
        {
            string         response;
            Calculator     calculator     = new Calculator();
            SpecialCommand specialCommand = new SpecialCommand();

            PrintHelpInformation();

            while (true)
            {
                ScanExpression();
                response = specialCommand.GetResponse(expression);

                if (response == "exit")
                {
                    break;
                }
                else
                if (expression != response)
                {
                    PrintResponse(response);
                }
                else
                {
                    response = CheckForFails.GetResponse(expression);

                    if (expression != response)
                    {
                        PrintResponse(response);
                    }
                    else
                    {
                        PrintResult(calculator.Calculate(expression));
                    }
                }
            }

            ExitMessage();
        }
예제 #3
0
 private static bool IsDigit(char previous, char current, int i)
 {
     if (Char.IsDigit(current) || current == ',' || (current == '-' && (i == 0 || (i > 0 && (previous == '(' || CheckForFails.isEmpty(previous.ToString()))))))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }