Skip to content

Commit e792cbc

Browse files
author
sailok.chinta
committed
feat: address review comments
1 parent d30fd84 commit e792cbc

File tree

1 file changed

+5
-41
lines changed

1 file changed

+5
-41
lines changed

src/main/java/com/thealgorithms/conversions/IntegerToEnglish.java

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,13 @@
11
package com.thealgorithms.conversions;
22

3-
import java.util.HashMap;
3+
import java.util.Map;
44

55
public final class IntegerToEnglish {
6-
private static final HashMap<Integer, String> BASE_NUMBERS_MAP = new HashMap<>() {
7-
{
8-
put(0, "");
9-
put(1, "One");
10-
put(2, "Two");
11-
put(3, "Three");
12-
put(4, "Four");
13-
put(5, "Five");
14-
put(6, "Six");
15-
put(7, "Seven");
16-
put(8, "Eight");
17-
put(9, "Nine");
18-
put(10, "Ten");
19-
put(11, "Eleven");
20-
put(12, "Twelve");
21-
put(13, "Thirteen");
22-
put(14, "Fourteen");
23-
put(15, "Fifteen");
24-
put(16, "Sixteen");
25-
put(17, "Seventeen");
26-
put(18, "Eighteen");
27-
put(19, "Nineteen");
28-
put(20, "Twenty");
29-
put(30, "Thirty");
30-
put(40, "Forty");
31-
put(50, "Fifty");
32-
put(60, "Sixty");
33-
put(70, "Seventy");
34-
put(80, "Eighty");
35-
put(90, "Ninety");
36-
put(100, "Hundred");
37-
}
38-
};
6+
private static final Map<Integer, String> BASE_NUMBERS_MAP = Map.ofEntries(Map.entry(0, ""), Map.entry(1, "One"), Map.entry(2, "Two"), Map.entry(3, "Three"), Map.entry(4, "Four"), Map.entry(5, "Five"), Map.entry(6, "Six"), Map.entry(7, "Seven"), Map.entry(8, "Eight"), Map.entry(9, "Nine"),
7+
Map.entry(10, "Ten"), Map.entry(11, "Eleven"), Map.entry(12, "Twelve"), Map.entry(13, "Thirteen"), Map.entry(14, "Fourteen"), Map.entry(15, "Fifteen"), Map.entry(16, "Sixteen"), Map.entry(17, "Seventeen"), Map.entry(18, "Eighteen"), Map.entry(19, "Nineteen"), Map.entry(20, "Twenty"),
8+
Map.entry(30, "Thirty"), Map.entry(40, "Forty"), Map.entry(50, "Fifty"), Map.entry(60, "Sixty"), Map.entry(70, "Seventy"), Map.entry(80, "Eighty"), Map.entry(90, "Ninety"), Map.entry(100, "Hundred"));
399

40-
private static final HashMap<Integer, String> THOUSAND_POWER_MAP = new HashMap<>() {
41-
{
42-
put(1, "Thousand");
43-
put(2, "Million");
44-
put(3, "Billion");
45-
}
46-
};
10+
private static final Map<Integer, String> THOUSAND_POWER_MAP = Map.ofEntries(Map.entry(1, "Thousand"), Map.entry(2, "Million"), Map.entry(3, "Billion"));
4711

4812
private IntegerToEnglish() {
4913
}

0 commit comments

Comments
 (0)