Beispiel #1
0
        public override SpelledNumber SpellOrdinal(ulong number, Gender gender = Gender.Neutral)
        {
            if (number < _settings.Magnitude)
            {
                return(InnerSpeller.SpellOrdinal(number, gender));
            }

            ulong numberOfUnits = number / _settings.Magnitude;
            ulong reminder      = number % _settings.Magnitude;

            if (reminder == 0)
            {
                string result = GetOrdinal(numberOfUnits, gender);

                SpelledNumber unitsOrdinalSpelled = new SpelledNumber(result, false);
                return(unitsOrdinalSpelled);
            }

            SpelledNumber unitsSpelled;

            if (numberOfUnits == 1)
            {
                unitsSpelled = new SpelledNumber(_settings.Singular, false);
            }
            else
            {
                SpelledNumber spelled = InnerSpeller.Spell(numberOfUnits, _settings.SpellingGender);

                unitsSpelled = new SpelledNumber(spelled.Spelled + _settings.PluralSuffix, spelled.ContainsAnd);
            }

            return(unitsSpelled.Concat(InnerSpeller.SpellOrdinal(reminder, gender)));
        }
Beispiel #2
0
        public override SpelledNumber SpellOrdinal(ulong number, Gender gender = Gender.Neutral)
        {
            if (number > 0)
            {
                return(InnerSpeller.SpellOrdinal(number, gender));
            }

            if (gender == Gender.Male)
            {
                return(new SpelledNumber("нулев", false));
            }
            else if (gender == Gender.Female)
            {
                return(new SpelledNumber("нулева", false));
            }

            return(new SpelledNumber("нулево", false));
        }
Beispiel #3
0
        public override SpelledNumber SpellOrdinal(ulong number, Gender gender = Gender.Neutral)
        {
            if (number < 100)
            {
                return(InnerSpeller.SpellOrdinal(number, gender));
            }

            ulong hundreds = (number / 100) * 100;
            ulong reminder = number % 100;

            if (reminder == 0)
            {
                string ordinalHundredsInWords = GetHundredsOrdinal(hundreds, gender);
                return(new SpelledNumber(ordinalHundredsInWords, false));
            }

            SpelledNumber hundredsInWords = new SpelledNumber(GetHundreds(hundreds), false);

            return(hundredsInWords.Concat(InnerSpeller.SpellOrdinal(reminder, gender)));
        }
Beispiel #4
0
        public override SpelledNumber SpellOrdinal(ulong number, Gender gender = Gender.Neutral)
        {
            if (number < 20)
            {
                return(InnerSpeller.SpellOrdinal(number, gender));
            }

            ulong tens     = (number / 10) * 10;
            ulong reminder = number % 10;

            if (reminder == 0)
            {
                string tensOrdinal = GetTensOrdinal(number, gender);
                return(new SpelledNumber(tensOrdinal, false));
            }

            string tensInWords = GetTens(tens);
            var    tensSpelled = new SpelledNumber(tensInWords, false);

            return(tensSpelled.Concat(InnerSpeller.SpellOrdinal(reminder, gender)));
        }
Beispiel #5
0
        public override SpelledNumber SpellOrdinal(ulong number, Gender gender = Gender.Neutral)
        {
            if (number < 10)
            {
                return(InnerSpeller.SpellOrdinal(number, gender));
            }

            string result;

            switch (number)
            {
            case 10: result = (gender == Gender.Male ? "десети" : gender == Gender.Female ? "десета" : "десето"); break;

            case 11: result = (gender == Gender.Male ? "единадесети" : gender == Gender.Female ? "единадесета" : "единадесето"); break;

            case 12: result = (gender == Gender.Male ? "дванадесети" : gender == Gender.Female ? "дванадесета" : "дванадесето"); break;

            case 13: result = (gender == Gender.Male ? "тринадесети" : gender == Gender.Female ? "тринадесета" : "тринадесето"); break;

            case 14: result = (gender == Gender.Male ? "четиринадесети" : gender == Gender.Female ? "четиринадесета" : "четиринадесето"); break;

            case 15: result = (gender == Gender.Male ? "петнадесети" : gender == Gender.Female ? "петнадесета" : "петнадесето"); break;

            case 16: result = (gender == Gender.Male ? "шестнадесети" : gender == Gender.Female ? "шестнадесета" : "шестнадесето"); break;

            case 17: result = (gender == Gender.Male ? "седемнадесети" : gender == Gender.Female ? "седемнадесета" : "седемнадесето"); break;

            case 18: result = (gender == Gender.Male ? "осемнадесети" : gender == Gender.Female ? "осемнадесета" : "осемнадесето"); break;

            case 19: result = (gender == Gender.Male ? "деветнадесети" : gender == Gender.Female ? "деветнадесета" : "деветнадесето"); break;

            default:
                throw new ArgumentOutOfRangeException(nameof(number), $"'{nameof(NumbersTo19Speller)}' is can't spell number {number}!");
            }

            return(new SpelledNumber(result, false));
        }