コード例 #1
0
        public decimal GetNumber(string whichNumber, OperatorType type)
        {
            SquareRootChecker squareRootCheck = new SquareRootChecker();
            decimal           returnValue     = 0;

            while (true)
            {
                if (squareRootCheck.SquareRootCheck(type) == SquareRootType.NotInUse)
                {
                    Console.WriteLine("\nEnter a " + whichNumber + " number for your equation: ");

                    string inputString = Console.ReadLine();
                    CheckForExit(inputString);


                    if (decimal.TryParse(inputString, out returnValue))
                    {
                        return(returnValue);
                    }
                    else
                    {
                        Console.WriteLine("Please enter valid integer");
                        continue;
                    }
                }
                return(returnValue);
            }
        }
コード例 #2
0
        public string FinalResultMessage(string _operator, decimal firstNumber, decimal secondNumber, decimal solution, OperatorType type)
        {
            SquareRootChecker squareRoot         = new SquareRootChecker();
            string            finalResultMessage = "";

            if (squareRoot.SquareRootCheck(type) == SquareRootType.InUse)
            {
                finalResultMessage = $"{_operator} {firstNumber} = {solution}";
            }
            else
            {
                finalResultMessage = $"{firstNumber} {_operator} {secondNumber} = {solution}";
            }
            return(finalResultMessage);
        }