コード例 #1
0
        public static Number TransformMathNumberToLetter(double numberToTransform)
        {
            Number number = new Number();

            if (numberToTransform.Equals(double.NaN))
            {
                string strError = "ERROR";
                number.ID                  = 0;
                number.Number_1            = numberToTransform;
                number.Number_1_French     = strError;
                number.Number_1_English    = strError;
                number.Number_1_Italian    = strError;
                number.Number_1_Spanish    = strError;
                number.Number_1_Portuguese = strError;
                number.Number_1_German     = strError;

                number.Number_result            = numberToTransform;
                number.Number_result_French     = strError;
                number.Number_result_English    = strError;
                number.Number_result_Italian    = strError;
                number.Number_result_Spanish    = strError;
                number.Number_result_Portuguese = strError;
                number.Number_result_German     = strError;
            }
            else
            {
                number.ID                  = 0;
                number.Number_1            = numberToTransform;
                number.Number_1_French     = NumberToWord.NumberToWords_French(numberToTransform);
                number.Number_1_English    = NumberToWord.NumberToWords_English((int)numberToTransform);
                number.Number_1_Italian    = NumberToWord.NumberToWords_Italian(numberToTransform);
                number.Number_1_Spanish    = NumberToWord.NumberToWords_Spanish(numberToTransform);
                number.Number_1_Portuguese = NumberToWord.NumberToWords_Portuguese(numberToTransform);
                number.Number_1_German     = NumberToWord.NumberToWords_German(numberToTransform);;

                number.Number_result            = numberToTransform;
                number.Number_result_French     = NumberToWord.NumberToWords_French(numberToTransform);
                number.Number_result_English    = NumberToWord.NumberToWords_English((int)numberToTransform);
                number.Number_result_Italian    = NumberToWord.NumberToWords_Italian(numberToTransform);
                number.Number_result_Spanish    = NumberToWord.NumberToWords_Spanish(numberToTransform);
                number.Number_result_Portuguese = NumberToWord.NumberToWords_Portuguese(numberToTransform);
                number.Number_result_German     = NumberToWord.NumberToWords_German(numberToTransform);
            }

            return(number);
        }
コード例 #2
0
        private static Number FillNumber(Enums.Level level, int randomNumber1, Enums.MathOperation operation, int randomNumber2, string strRandomNumber1, string strRandomNumber2)//, double result)
        {
            //double result = Calculate(randomNumber1, operation, randomNumber2);
            // CALCULATE
            string formula = string.Format("{0} {1} {2}", strRandomNumber1, ConvertEnums.ConvertMathOperation(operation), strRandomNumber2);
            double result  = CalculateMathFormula(formula); //.Replace(" ",""));
            //if (result.Equals(double.NaN))
            //    result = 0.00;

            Number number = new Number();

            if (result.Equals(double.NaN))
            {
                string strError = "ERROR";
                number.ID                                   = 0;
                number.Number_1                             = randomNumber1;
                number.Number_1_French                      = strError;
                number.Number_1_English                     = strError;
                number.Number_1_Italian                     = strError;
                number.Number_1_Spanish                     = strError;
                number.Number_1_Portuguese                  = strError;
                number.Number_1_German                      = strError;
                number.Number_operation                     = operation;
                number.Number_2                             = randomNumber2;
                number.Number_2_French                      = strError;
                number.Number_2_English                     = strError;
                number.Number_2_Italian                     = strError;
                number.Number_2_Spanish                     = strError;
                number.Number_2_Portuguese                  = strError;
                number.Number_2_German                      = strError;
                number.Number_result                        = result;
                number.Number_result_French                 = strError;
                number.Number_result_English                = strError;
                number.Number_result_Italian                = strError;
                number.Number_result_Spanish                = strError;
                number.Number_result_Portuguese             = strError;
                number.Number_result_German                 = strError;
                number.Number_equation_LessOrGreaterOrEqual = (strRandomNumber1 + " ? " + strRandomNumber2);

                number.Number_result_LessOrGreaterOrEqual = strError;

                number.Number_equation            = string.Format("{0} {1} {2} = ?", strRandomNumber1, ConvertEnums.ConvertMathOperation(operation), strRandomNumber2);
                number.Number_equation_French     = string.Format("{0} {1} {2} = ?", number.Number_1_French, ConvertEnums.ConvertMathOperation_French(operation), number.Number_2_French);
                number.Number_equation_English    = string.Format("{0} {1} {2} = ?", number.Number_1_English, ConvertEnums.ConvertMathOperation_English(operation), number.Number_2_English);
                number.Number_equation_Italian    = string.Format("{0} {1} {2} = ?", number.Number_1_Italian, ConvertEnums.ConvertMathOperation_Italian(operation), number.Number_2_Italian);
                number.Number_equation_Spanish    = string.Format("{0} {1} {2} = ?", number.Number_1_Spanish, ConvertEnums.ConvertMathOperation_Spanish(operation), number.Number_2_Spanish);
                number.Number_equation_Portuguese = string.Format("{0} {1} {2} = ?", number.Number_1_Portuguese, ConvertEnums.ConvertMathOperation_Portuguese(operation), number.Number_2_Portuguese);
                number.Number_equation_German     = string.Format("{0} {1} {2} = ?", number.Number_1_German, ConvertEnums.ConvertMathOperation_German(operation), number.Number_2_German);
            }
            else
            {
                number.ID                                   = 0;
                number.Number_1                             = randomNumber1;
                number.Number_1_French                      = NumberToWord.NumberToWords_French(randomNumber1);
                number.Number_1_English                     = NumberToWord.NumberToWords_English(randomNumber1);
                number.Number_1_Italian                     = NumberToWord.NumberToWords_Italian(randomNumber1);
                number.Number_1_Spanish                     = NumberToWord.NumberToWords_Spanish(randomNumber1);
                number.Number_1_Portuguese                  = NumberToWord.NumberToWords_Portuguese(randomNumber1);
                number.Number_1_German                      = NumberToWord.NumberToWords_German(randomNumber1);
                number.Number_operation                     = operation;
                number.Number_2                             = randomNumber2;
                number.Number_2_French                      = NumberToWord.NumberToWords_French(randomNumber2);
                number.Number_2_English                     = NumberToWord.NumberToWords_English(randomNumber2);
                number.Number_2_Italian                     = NumberToWord.NumberToWords_Italian(randomNumber2);
                number.Number_2_Spanish                     = NumberToWord.NumberToWords_Spanish(randomNumber2);
                number.Number_2_Portuguese                  = NumberToWord.NumberToWords_Portuguese(randomNumber2);
                number.Number_2_German                      = NumberToWord.NumberToWords_German(randomNumber2);
                number.Number_result                        = result;
                number.Number_result_French                 = NumberToWord.NumberToWords_French(result);
                number.Number_result_English                = NumberToWord.NumberToWords_English((int)result);
                number.Number_result_Italian                = NumberToWord.NumberToWords_Italian(result);
                number.Number_result_Spanish                = NumberToWord.NumberToWords_Spanish(result);
                number.Number_result_Portuguese             = NumberToWord.NumberToWords_Portuguese(result);
                number.Number_result_German                 = NumberToWord.NumberToWords_German(result);
                number.Number_equation_LessOrGreaterOrEqual = (strRandomNumber1 + " ? " + strRandomNumber2);

                string strResultGreaterOrLessThan = "";
                if (number.Number_1 > number.Number_2)
                {
                    strResultGreaterOrLessThan = ">";
                }
                else if (number.Number_1 < number.Number_2)
                {
                    strResultGreaterOrLessThan = "<";
                }
                else if (number.Number_1 == number.Number_2)
                {
                    strResultGreaterOrLessThan = "=";
                }
                number.Number_result_LessOrGreaterOrEqual = strResultGreaterOrLessThan;

                number.Number_equation            = string.Format("{0} {1} {2} = ?", strRandomNumber1, ConvertEnums.ConvertMathOperation(operation), strRandomNumber2);
                number.Number_equation_French     = string.Format("{0} {1} {2} = ?", number.Number_1_French, ConvertEnums.ConvertMathOperation_French(operation), number.Number_2_French);
                number.Number_equation_English    = string.Format("{0} {1} {2} = ?", number.Number_1_English, ConvertEnums.ConvertMathOperation_English(operation), number.Number_2_English);
                number.Number_equation_Italian    = string.Format("{0} {1} {2} = ?", number.Number_1_Italian, ConvertEnums.ConvertMathOperation_Italian(operation), number.Number_2_Italian);
                number.Number_equation_Spanish    = string.Format("{0} {1} {2} = ?", number.Number_1_Spanish, ConvertEnums.ConvertMathOperation_Spanish(operation), number.Number_2_Spanish);
                number.Number_equation_Portuguese = string.Format("{0} {1} {2} = ?", number.Number_1_Portuguese, ConvertEnums.ConvertMathOperation_Portuguese(operation), number.Number_2_Portuguese);
                number.Number_equation_German     = string.Format("{0} {1} {2} = ?", number.Number_1_German, ConvertEnums.ConvertMathOperation_German(operation), number.Number_2_German);
            }
            return(number);
        }