コード例 #1
0
        public string BuildSentance()
        {
            var words = new Conjunctor(" and ");

            words.Append(_hundredsValue);
            words.Append(_sometyValue);
            return(words.ToString());
        }
コード例 #2
0
        private string AssembleFromWordsAndName(string wordPart, string partname)
        {
            if (string.IsNullOrWhiteSpace(wordPart))
            {
                return(string.Empty);
            }
            var conjunctor = new Conjunctor(" ");

            conjunctor.Append(wordPart);
            conjunctor.Append(partname);
            return(conjunctor.ToString());
        }
コード例 #3
0
        public string ToWords(string input)
        {
            var decimalPointPos = input.IndexOf(".", StringComparison.InvariantCultureIgnoreCase);
            var integerPart     = decimalPointPos < 0 ? input : input.Substring(0, decimalPointPos);
            var fractionalPart  = decimalPointPos < 0 || decimalPointPos == input.Length - 1 ? string.Empty : input.Substring(decimalPointPos + 1);
            var dollarWords     = ToWords(integerPart, "dollars", "one dollar");
            var centWords       = ToWords(fractionalPart, "cents", "one cent");

            var conjuctor = new Conjunctor(" and ");

            conjuctor.Append(dollarWords);
            conjuctor.Append(centWords);
            return(conjuctor.ToString());
        }
コード例 #4
0
        private string AssembleWithCommas(List <string> sentanceParts)
        {
            var length     = sentanceParts.Count;
            var conjunctor = new Conjunctor(", ");
            int i          = 0;

            while (i <= length - 2)
            {
                conjunctor.Append(sentanceParts[i]);
                i++;
            }

            var sofar = conjunctor.ToString();

            return($"{sofar} {sentanceParts[length - 1]}");
        }