protected override string Case(long value, WordInfo info) { value = value % 100; if (value > GetFixedWordsCount()) { value = value % 10; } switch (value) { case 1: return(info.one); case 2: case 3: case 4: return(info.two); default: return(info.many); } }
private string Str(decimal value, WordInfo senior, WordInfo junior) { bool minus = false; if (value < 0) { value = -value; minus = true; } long n = (long)value; int remainder = (int)((value - n + 0.005m) * 100); if (remainder >= 100) { n++; remainder = 0; } StringBuilder r = new StringBuilder(); Str(n, senior, r); if (minus) { r.Insert(0, GetMinus() + " "); } if (junior != null) { r.Append(GetDecimalSeparator() + remainder.ToString("00 ")); r.Append(Case(remainder, junior)); } r[0] = char.ToUpper(r[0]); return(r.ToString()); }
protected override string Str1000(long value, WordInfo info, int counter) { long val = value % 1000; if (val == 0) { return(""); } StringBuilder r = new StringBuilder(); // add hundred string hund = GetHund(info.male, val); if (hund != "") { r.Append(hund); } // decide whether to use the 100-10 separator or not string sep100_10 = Get100_10Separator(); if (value < 1000 && hund == "") { sep100_10 = ""; } val = val % 100; if (counter == 3 || counter == 4 || counter == 5) { _useUn = true; } else { _useUn = false; } if (val > 20 && val < 30) { r.Append(sep100_10 + fixedWords21To29[val - 21]); } else if (val < GetFixedWordsCount()) { // val is less than fixed words count (usually 20), get fixed words string frac20 = GetFixedWords(info.male, val); if (frac20 != "") { r.Append(sep100_10 + frac20); } } else { // val is greater than fixed words count (usually 20), get tens separately string ten = GetTen(info.male, val / 10); string frac10 = GetFixedWords(info.male, val % 10); // decide whether to use 10-1 separator or not if (ten != "" && frac10 != "") { r.Append(sep100_10 + ten + Get10_1Separator() + frac10); } else if (ten != "") { r.Append(sep100_10 + ten); } else if (frac10 != "") { r.Append(sep100_10 + frac10); } } // add currency/group word r.Append(" "); r.Append(Case(value, info)); // make the result starting with letter and ending with space if (r.Length != 0) { r.Append(" "); } return(r.ToString().TrimStart(new char[] { ' ' })); }
protected override string Str1000(long value, WordInfo info, int counter) { long val = value % 1000; if (val == 0) { return(""); } StringBuilder r = new StringBuilder(); // add hundred string hund = GetHund(info.male, val); if (hund != "") { r.Append(hund); } val = val % 100; if (val < GetFixedWordsCount()) { // val is less than fixed words count (usually 20), get fixed words string frac20 = GetFixedWords(info.male, val); if (frac20 != "") { r.Append(frac20); } } else { // val is greater than fixed words count (usually 20), get tens separately string ten = GetTen(info.male, val / 10); string frac10 = GetFixedWords(info.male, val % 10); // decide whether to use 10-1 separator or not if (ten != "" && frac10 != "") { r.Append(frac10 + "und" + ten); } else if (ten != "") { r.Append(ten); } else if (frac10 != "") { r.Append(frac10); } } string separator = counter == 2 ? "" : " "; // thousands do not use separator // add currency/group word r.Append(separator); r.Append(Case(value, info)); // make the result starting with letter and ending with space if (r.Length != 0) { r.Append(separator); } return(r.ToString().TrimStart(new char[] { ' ' })); }
public CurrencyInfo(WordInfo senior, WordInfo junior) { Senior = senior; Junior = junior; }
public CurrencyInfo(WordInfo senior, WordInfo junior) { this.senior = senior; this.junior = junior; }
protected override string Str1000(long value, WordInfo info, int counter) { long val; //if its third or if (counter == 3 || counter == 4) { shouldReturnMany = true; } else { shouldReturnMany = false; } if (counter == 1) { val = value % 1000; } else { val = value % 100; } if (val == 0) { return(""); } StringBuilder r = new StringBuilder(); // add hundred string hund = GetHund(info.male, val); if (hund != "") { r.Append(hund); } // decide whether to use the 100-10 separator or not string sep100_10 = Get100_10Separator(); if (value < 1000 && hund == "") { sep100_10 = ""; } val = val % 100; if (val < GetFixedWordsCount()) { // val is less than fixed words count (usually 20), get fixed words string frac20 = GetFixedWords(info.male, val); if (frac20 != "") { r.Append(sep100_10 + frac20); } } else { // val is greater than fixed words count (usually 20), get tens separately string ten = GetTen(info.male, val / 10); string frac10 = GetFixedWords(info.male, val % 10); // decide whether to use 10-1 separator or not if (ten != "" && frac10 != "") { r.Append(sep100_10 + ten + Get10_1Separator() + frac10); } else if (ten != "") { r.Append(sep100_10 + ten); } else if (frac10 != "") { r.Append(sep100_10 + frac10); } } //Twenty-Four crore and seventy-Five lakh and Eighty-Zero thousand rupees and 00 paise // add currency/group word r.Append(" "); if (counter == 1 && value % 100 != 1) { shouldReturnMany = true; } r.Append(Case(value, info)); // make the result starting with letter and ending with space if (r.Length != 0) { r.Append(" "); } return(r.ToString().TrimStart(new char[] { ' ' })); }
protected override string Str1000(long value, WordInfo info, int counter) { long val = value % 1000; if (val == 0) { return(""); } StringBuilder r = new StringBuilder(); // add hundred string hund = GetHund(info.male, val); if (hund != "") { r.Append(hund); } // decide whether to use the 100-10 separator or not string sep100_10 = Get100_10Separator(); if (value < 1000 && hund == "") { sep100_10 = ""; } val = val % 100; if (val < 20) { r.Append(sep100_10 + GetFixedWords(info.male, val)); } else if (val > 70 && val < 80) { r.Append(sep100_10 + fixedWords71to79[val - 71]); } else if (val > 90 && val < 100) { r.Append(sep100_10 + fixedWords91to99[val - 91]); } else { // val is greater than fixed words count (usually 20), get tens separately string ten = GetTen(info.male, val / 10); string frac10 = GetFixedWords(info.male, val % 10); // decide whether to use 10-1 separator or not if (ten != "" && frac10 != "") { string sep10_1 = "-"; if (val % 10 == 1) { if (val / 10 != 8) { sep10_1 = " et "; } } r.Append(sep100_10 + ten + sep10_1 + frac10); } else if (ten != "") { r.Append(sep100_10 + ten); } else if (frac10 != "") { r.Append(sep100_10 + frac10); } } // special cases if (counter == 1) // the final { // 80 ends with 's' in case it's the final word if (val == 80) { r.Append("s"); } // 100's ends with 's' in case it's the final word if (val == 0 && value % 1000 > 100) { r.Append("s"); } } // add currency/group word r.Append(" "); r.Append(Case(value, info)); // make the result starting with letter and ending with space if (r.Length != 0) { r.Append(" "); } return(r.ToString().TrimStart(new char[] { ' ' })); }