コード例 #1
0
        public static Number GenerateMath(int level)
        {
            // Dictée de nombre
            int    randomNumber   = GetRandomValue(0, level * level * 99);
            string englishNumber1 = NumberToWord.NumberToWords_English(randomNumber);
            string frenchNumber1  = NumberToWord.NumberToWords_French(randomNumber);

            Number number = new Number();

            number = FillNumber((Enums.Level)Settings.counterLevel, randomNumber, Enums.MathOperation.Addition, 0, randomNumber.ToString(), "0");
            return(number);

            //int randomNumber = 2593; //
            //int numberResponse = 2592;

            // Params init
            //Settings.counterGoodAnswers = 0;

            //for (int counterGame = 0; counterGame < SettingsApp.Default.paramMaxCounterGame; counterGame++)
            {
                //Mathmode = mode;
                //string englishNumber1 = NumberToWord.NumberToWords_English(randomNumber);
                //string frenchNumber1 = NumberToWord.NumberToWords_French(randomNumber);
                //
                //Helpers.Speaker speaker = new Helpers.Speaker();
                //speaker.SpeakText(SettingsApp.Default.paramVoiceEnglish, englishNumber1);
                //speaker.SpeakText(SettingsApp.Default.paramVoiceFrench, frenchNumber1);

                //bool resultOK = false;
                //Settings.counterWrongTry = 0;
                ////for (int counterTry = 0; counterTry < SettingsApp.Default.paramMaxWrongTry; counterTry++)
                //{
                //    if (randomNumber == numberResponse)
                //    {
                //        resultOK = true;
                //        break;
                //    }
                //    Settings.counterWrongTry++;
                //}

                // Counters
                //if (resultOK)
                //    Settings.counterGoodAnswers++;
                //else
                //    Settings.counterWrongAnswers++;

                //counterGame++;
                //if (counterGame >= SettingsApp.Default.paramMaxCounterGame)
                //    break;
            }

            //Set Display
            //Settings.displayResultGoodAnswers = Settings.counterGoodAnswers + "/" + SettingsApp.Default.paramMaxCounterGame;
            //
            //Number number = new Number();
            //return number;
        }
コード例 #2
0
        public static Number GenerateNumberStumper()
        {
            // Random pour nombre à 4 chiffres
            int    randomNumber   = GetRandomValueLength(4);
            string englishNumber1 = NumberToWord.NumberToWords_English(randomNumber);
            string frenchNumber1  = NumberToWord.NumberToWords_French(randomNumber);
            Number number         = new Number();

            //number = FillNumber((Enums.Level)Settings.counterLevel, randomNumber, Enums.MathOperation.Addition, 0, randomNumber.ToString(), "0");
            number = TransformMathNumberToLetter(randomNumber);
            return(number);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }