Introduction
So after a long (almost 13 days) time, I am going to take my article to the next level.
Have a look at my previous article:
First walk through the base article. In this article, you will find extension only to that article.
Background
Let's have a look at the snapshots.
For Indian
For International
Using the Code
So let me start by depicting the extension points to the previous article.
First, I have added one enumeration, which is about to be passed at the constructor of the class and will be set to global variable for program to know in which type to convert.
public enum Criteria
{
Indian,
Foreign
}
Another change is in which pattern data is to be filled to hashtable.
E.g.
In Indian currency, you can split 234445443345345
into 23,44,45,44,33,45,345
( I mean first group of three digit and then 2 digits).
In foreign currency, you can split 234445443345345
into 234,445,443,345,345
(I mean groups of three digits).
So as per that, I will also need to change the way data is filling to hashtable.
Take a look:
private void InsertToPunctuationTable(string strValue)
{
int j = 0;
if (Native == Criteria.Indian)
{
htPunctuation.Add(1, strValue.Substring(0, 3).ToString());
j = 2;
for (int i = 3; i < strValue.Length; i = i + 2)
{
if (strValue.Substring(i).Length > 0)
{
if (strValue.Substring(i).Length >= 2)
htPunctuation.Add(j, strValue.Substring(i, 2).ToString());
else
htPunctuation.Add(j, strValue.Substring(i, 1).ToString());
}
else
break;
j++;
}
}
if (Native == Criteria.Foreign)
{
for (int i = 0; i < strValue.Length; i = i + 3)
{
if (strValue.Substring(i).Length > 0)
{
if (strValue.Substring(i).Length >= 3)
htPunctuation.Add(j, strValue.Substring(i, 3).ToString());
else
htPunctuation.Add(j, strValue.Substring(i).ToString());
}
j++;
}
}
}
For Indian currency, I have depicted hashtable picture in the previous article. Now take a look at the hashtable data on foreign condition:
Same way differentiate Notation.
private void LoadStaticPrefix()
{
if (Native == Criteria.Indian)
{
DictStaticPrefix.Add(2, "Thousand ");
DictStaticPrefix.Add(3, "Lac ");
DictStaticPrefix.Add(4, "Crore ");
DictStaticPrefix.Add(5, "Arab ");
DictStaticPrefix.Add(6, "Kharab ");
DictStaticPrefix.Add(7, "Neel ");
DictStaticPrefix.Add(8, "Padma ");
DictStaticPrefix.Add(9, "Shankh ");
DictStaticPrefix.Add(10, "Maha-shankh ");
DictStaticPrefix.Add(11, "Ank ");
DictStaticPrefix.Add(12, "Jald ");
DictStaticPrefix.Add(13, "Madh ");
DictStaticPrefix.Add(14, "Paraardha ");
DictStaticPrefix.Add(15, "Ant ");
DictStaticPrefix.Add(16, "Maha-ant ");
DictStaticPrefix.Add(17, "Shisht ");
DictStaticPrefix.Add(18, "Singhar ");
DictStaticPrefix.Add(19, "Maha-singhar ");
DictStaticPrefix.Add(20, "Adant-singhar ");
}
if (Native == Criteria.Foreign)
{
DictStaticPrefix.Add(1, "Thousand ");
DictStaticPrefix.Add(2, "Million ");
DictStaticPrefix.Add(3, "Billion ");
DictStaticPrefix.Add(4, "Trillion ");
DictStaticPrefix.Add(5, "Quadrillion ");
DictStaticPrefix.Add(6, "Quintillion ");
DictStaticPrefix.Add(7, "Sextillion ");
DictStaticPrefix.Add(8, "Septillion ");
DictStaticPrefix.Add(9, "Octillion ");
DictStaticPrefix.Add(10, "Nonillion ");
DictStaticPrefix.Add(11, "Decillion ");
DictStaticPrefix.Add(12, "Undecillion ");
DictStaticPrefix.Add(13, "Duodecillion ");
}
}
These all are extensions to the previous article, rest is the same as previous.
Points of Interest
This is Part-II, if anybody wants it in another notation as well, give me the notation, will I publish it as part-III.
History
- 10th September, 2010: Initial post