RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.util.Words Class Reference

This class specially written to convert the given number into words. More...

Public Member Functions

String belowBillion (long x)
String belowCrore (long x)
long getNumber ()
String getNumberInWords ()
long leftChars (int n)
long leftChars (long num, int n)
int length (long num)
long rightChars (int n)
long rightChars (long num, int n)
void setNumber (long num)

Static Public Member Functions

static Words getInstance (long num)
static String leftChars (String str, int n)
static String rightChars (String str, int n)

Package Attributes

long num

Private Member Functions

String belowHundred (long x)
String belowLakh (long x)
String belowTen (long x)
String belowThousand (long x)
String belowTwenty (long x)
 Words ()
 Words (long num)

Detailed Description

This class specially written to convert the given number into words.

It will support upto 1 crore.

Author
SANTHOSH REDDY MANDADI
Version
release: 2_0_48
Since
April 03 2008

Definition at line 11 of file Words.java.

Constructor & Destructor Documentation

◆ Words() [1/2]

com.runehive.util.Words.Words ( )
private

Definition at line 14 of file Words.java.

14 {
15 num = 0;
16 }

References num.

Referenced by getInstance().

Here is the caller graph for this function:

◆ Words() [2/2]

com.runehive.util.Words.Words ( long num)
private

Definition at line 18 of file Words.java.

18 {
19 this.num = num;
20 }

References num.

Member Function Documentation

◆ belowBillion()

String com.runehive.util.Words.belowBillion ( long x)

Definition at line 188 of file Words.java.

188 {
189 if (x < 10)
190 return belowTen(x);
191 else if (x < 20)
192 return belowTwenty(x);
193 else if (x < 100)
194 return belowHundred(x);
195 else if (x < 1000)
196 return belowThousand(x);
197 else if (x < 100000)
198 return belowLakh(x);
199 else if (x < 100000000)
200 return belowCrore(x);
201
202 if (length(x) == 8)
203 return belowTen(leftChars(x, 1)) + "Bilion " + belowCrore(rightChars(x, 7));
204 else
205 return belowHundred(leftChars(x, 2)) + "Bilion " + belowCrore(rightChars(x, 7));
206 }

References belowCrore(), belowHundred(), belowLakh(), belowTen(), belowThousand(), belowTwenty(), leftChars(), length(), and rightChars().

Referenced by getNumberInWords().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ belowCrore()

String com.runehive.util.Words.belowCrore ( long x)

Definition at line 171 of file Words.java.

171 {
172 if (x < 10)
173 return belowTen(x);
174 else if (x < 20)
175 return belowTwenty(x);
176 else if (x < 100)
177 return belowHundred(x);
178 else if (x < 1000)
179 return belowThousand(x);
180 else if (x < 100000)
181 return belowLakh(x);
182 if (length(x) == 6)
183 return belowTen(leftChars(x, 1)) + "Lakh " + belowLakh(rightChars(x, 5));
184 else
185 return belowHundred(leftChars(x, 2)) + "Lakh " + belowLakh(rightChars(x, 5));
186 }

References belowHundred(), belowLakh(), belowTen(), belowThousand(), belowTwenty(), leftChars(), length(), and rightChars().

Referenced by belowBillion(), and getNumberInWords().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ belowHundred()

String com.runehive.util.Words.belowHundred ( long x)
private

Definition at line 120 of file Words.java.

120 {
121 if (x < 10)
122 return belowTen(x);
123 else if (x < 20)
124 return belowTwenty(x);
125 switch ((int) leftChars(x, 1)) {
126 case 2:
127 return "Twenty " + belowTen(rightChars(x, 1));
128 case 3:
129 return "Thirty " + belowTen(rightChars(x, 1));
130 case 4:
131 return "Fourty " + belowTen(rightChars(x, 1));
132 case 5:
133 return "Fifty " + belowTen(rightChars(x, 1));
134 case 6:
135 return "Sixty " + belowTen(rightChars(x, 1));
136 case 7:
137 return "Seventy " + belowTen(rightChars(x, 1));
138 case 8:
139 return "Eighty " + belowTen(rightChars(x, 1));
140 case 9:
141 return "Ninety " + belowTen(rightChars(x, 1));
142 }
143 return "";
144 }

References belowTen(), belowTwenty(), leftChars(), and rightChars().

Referenced by belowBillion(), belowCrore(), belowLakh(), belowThousand(), and getNumberInWords().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ belowLakh()

String com.runehive.util.Words.belowLakh ( long x)
private

Definition at line 156 of file Words.java.

156 {
157 if (x < 10)
158 return belowTen(x);
159 else if (x < 20)
160 return belowTwenty(x);
161 else if (x < 100)
162 return belowHundred(x);
163 else if (x < 1000)
164 return belowThousand(x);
165 if (length(x) == 4)
166 return belowTen(leftChars(x, 1)) + "Thousand " + belowThousand(rightChars(x, 3));
167 else
168 return belowHundred(leftChars(x, 2)) + "Thousand " + belowThousand(rightChars(x, 3));
169 }

References belowHundred(), belowTen(), belowThousand(), belowTwenty(), leftChars(), length(), and rightChars().

Referenced by belowBillion(), belowCrore(), and getNumberInWords().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ belowTen()

String com.runehive.util.Words.belowTen ( long x)
private

Definition at line 68 of file Words.java.

68 {
69 switch ((int) x) {
70 case 1:
71 return "One ";
72 case 2:
73 return "Two ";
74 case 3:
75 return "Three ";
76 case 4:
77 return "Four ";
78 case 5:
79 return "Five ";
80 case 6:
81 return "Six ";
82 case 7:
83 return "Seven ";
84 case 8:
85 return "Eight ";
86 case 9:
87 return "Nine ";
88 }
89 return "";
90 }

Referenced by belowBillion(), belowCrore(), belowHundred(), belowLakh(), belowThousand(), belowTwenty(), and getNumberInWords().

Here is the caller graph for this function:

◆ belowThousand()

String com.runehive.util.Words.belowThousand ( long x)
private

Definition at line 146 of file Words.java.

146 {
147 if (x < 10)
148 return belowTen(x);
149 else if (x < 20)
150 return belowTwenty(x);
151 else if (x < 100)
152 return belowHundred(x);
153 return belowTen(leftChars(x, 1)) + "Hundred " + belowHundred(rightChars(x, 2));
154 }

References belowHundred(), belowTen(), belowTwenty(), leftChars(), and rightChars().

Referenced by belowBillion(), belowCrore(), belowLakh(), and getNumberInWords().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ belowTwenty()

String com.runehive.util.Words.belowTwenty ( long x)
private

Definition at line 92 of file Words.java.

92 {
93 if (x < 10)
94 return belowTen(x);
95 switch ((int) x) {
96 case 10:
97 return "Ten ";
98 case 11:
99 return "Eleven ";
100 case 12:
101 return "Twelve ";
102 case 13:
103 return "Thirteen ";
104 case 14:
105 return "Fourteen ";
106 case 15:
107 return "Fifteen ";
108 case 16:
109 return "Sixteen ";
110 case 17:
111 return "Seventeen ";
112 case 18:
113 return "Eighteen ";
114 case 19:
115 return "Nineteen ";
116 }
117 return "";
118 }

References belowTen().

Referenced by belowBillion(), belowCrore(), belowHundred(), belowLakh(), belowThousand(), and getNumberInWords().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInstance()

Words com.runehive.util.Words.getInstance ( long num)
static

Definition at line 30 of file Words.java.

30 {
31 return new Words(num);
32 }

References num, and Words().

Referenced by com.runehive.util.Utility.convertWord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNumber()

long com.runehive.util.Words.getNumber ( )

Definition at line 26 of file Words.java.

26 {
27 return num;
28 }

References num.

◆ getNumberInWords()

String com.runehive.util.Words.getNumberInWords ( )

Definition at line 208 of file Words.java.

208 {
209 if (num < 10)
210 return belowTen(num);
211 else if (num < 20)
212 return belowTwenty(num);
213 else if (num < 100)
214 return belowHundred(num);
215 else if (num < 1000)
216 return belowThousand(num);
217 else if (num < 100000)
218 return belowLakh(num);
219 else if (num < 10000000)
220 return belowCrore(num);
221 else if (num < 1000000000)
222 return belowBillion(num);
223 return "";
224 }

References belowBillion(), belowCrore(), belowHundred(), belowLakh(), belowTen(), belowThousand(), belowTwenty(), and num.

Referenced by com.runehive.util.Utility.convertWord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ leftChars() [1/3]

long com.runehive.util.Words.leftChars ( int n)

Definition at line 48 of file Words.java.

48 {
49 return Long.parseLong(leftChars(Long.toString(num), n));
50 }

References leftChars(), and num.

Here is the call graph for this function:

◆ leftChars() [2/3]

long com.runehive.util.Words.leftChars ( long num,
int n )

Definition at line 56 of file Words.java.

56 {
57 return Long.parseLong(leftChars(Long.toString(num), n));
58 }

References leftChars(), and num.

Here is the call graph for this function:

◆ leftChars() [3/3]

String com.runehive.util.Words.leftChars ( String str,
int n )
static

Definition at line 34 of file Words.java.

34 {
35 if (str.length() <= n)
36 return str;
37 else
38 return str.substring(0, n);
39 }

Referenced by belowBillion(), belowCrore(), belowHundred(), belowLakh(), belowThousand(), leftChars(), and leftChars().

Here is the caller graph for this function:

◆ length()

int com.runehive.util.Words.length ( long num)

Definition at line 64 of file Words.java.

64 {
65 return Long.toString(num).length();
66 }

References num.

Referenced by belowBillion(), belowCrore(), and belowLakh().

Here is the caller graph for this function:

◆ rightChars() [1/3]

long com.runehive.util.Words.rightChars ( int n)

Definition at line 52 of file Words.java.

52 {
53 return Long.parseLong(rightChars(Long.toString(num), n));
54 }

References num, and rightChars().

Here is the call graph for this function:

◆ rightChars() [2/3]

long com.runehive.util.Words.rightChars ( long num,
int n )

Definition at line 60 of file Words.java.

60 {
61 return Long.parseLong(rightChars(Long.toString(num), n));
62 }

References num, and rightChars().

Here is the call graph for this function:

◆ rightChars() [3/3]

String com.runehive.util.Words.rightChars ( String str,
int n )
static

Definition at line 41 of file Words.java.

41 {
42 if (str.length() <= n)
43 return str;
44 else
45 return str.substring(str.length() - n);
46 }

Referenced by belowBillion(), belowCrore(), belowHundred(), belowLakh(), belowThousand(), rightChars(), and rightChars().

Here is the caller graph for this function:

◆ setNumber()

void com.runehive.util.Words.setNumber ( long num)

Definition at line 22 of file Words.java.

22 {
23 this.num = num;
24 }

References num.

Member Data Documentation

◆ num

long com.runehive.util.Words.num
package

The documentation for this class was generated from the following file: