This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void convert_shouldReturnV() { | |
final String romanNumeral = RomanNumerals.convert(5); | |
assertThat(romanNumeral, is("V")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RomanNumerals { | |
public static String convert(int number) { | |
if (number == 5) { | |
return "V"; | |
} | |
return "I"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RomanNumeralsTest { | |
@Test | |
public void convert_shouldReturnI() { | |
final String romanNumeral = RomanNumerals.convert(1); | |
assertThat(romanNumeral, is("I")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RomanNumerals { | |
public static String convert(int number) { | |
if (number == 5) { | |
return "V"; | |
} else if (number ==10) { | |
return "X"; | |
} else if (number == 50) { | |
return "L"; | |
} else if (number == 100) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
public class RomanNumerals { | |
private static final Map<Integer, String> ROMAN_NUMERALS = Map.of( | |
1, "I", | |
5, "V", | |
10, "X", | |
50, "L", | |
100, "C", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void convert_shouldReturnII() { | |
final String romanNumeral = RomanNumerals.convert(2); | |
assertThat(romanNumeral, is("II")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RomanNumerals { | |
private static final NavigableMap<Integer, String> ROMAN_NUMERALS = new TreeMap<>() { | |
{ | |
put(1, "I"); | |
put(5, "V"); | |
put(10, "X"); | |
put(50, "L"); | |
put(100, "C"); | |
put(500, "D"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RomanNumerals { | |
private static final NavigableMap<Integer, String> ROMAN_NUMERALS = new TreeMap<>() { | |
{ | |
put(1, "I"); | |
put(5, "V"); | |
put(10, "X"); | |
put(50, "L"); | |
put(100, "C"); | |
put(500, "D"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void convert_shouldReturnIII() { | |
final String romanNumeral = RomanNumerals.convert(3); | |
assertThat(romanNumeral, is("III")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RomanNumerals { | |
private static final NavigableMap<Integer, String> ROMAN_NUMERALS = new TreeMap<>() { | |
{ | |
put(1, "I"); | |
put(5, "V"); | |
put(10, "X"); | |
put(50, "L"); | |
put(100, "C"); | |
put(500, "D"); |