Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
twitch
live-coding-fr
Commits
435dc53b
Commit
435dc53b
authored
Nov 24, 2020
by
Colin DAMON
Browse files
Create conversion map
parent
72b71807
Changes
1
Hide whitespace changes
Inline
Side-by-side
tcr-roman-numerals/src/main/java/fr/ippon/kata/numeral/Numerals.java
View file @
435dc53b
package
fr.ippon.kata.numeral
;
import
java.util.NavigableMap
;
import
java.util.TreeMap
;
public
class
Numerals
{
private
static
final
NavigableMap
<
Integer
,
String
>
CONVERSIONS
=
buildConversions
();
public
static
String
toRoman
(
int
arabic
)
{
if
(
arabic
>=
5
)
{
...
...
@@ -13,4 +17,14 @@ public class Numerals {
return
"I"
.
repeat
(
arabic
);
}
private
static
NavigableMap
<
Integer
,
String
>
buildConversions
()
{
NavigableMap
<
Integer
,
String
>
conversions
=
new
TreeMap
<>();
conversions
.
put
(
1
,
"I"
);
conversions
.
put
(
4
,
"IV"
);
conversions
.
put
(
5
,
"V"
);
return
conversions
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment