From: Gustavo Martin Morcuende Date: Sun, 27 Nov 2016 16:49:42 +0000 (+0100) Subject: Writing test for VII X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=15794a4a28a2c07f24dd4cc950dcfa5d8d7cdec0;p=JavaForFun Writing test for VII --- diff --git a/TDD/sandromancuso/romannumerals/src/main/java/org/craftedsw/romannumerals/RomanNumeralGenerator.java b/TDD/sandromancuso/romannumerals/src/main/java/org/craftedsw/romannumerals/RomanNumeralGenerator.java index 0dabe1f..17bc8f3 100644 --- a/TDD/sandromancuso/romannumerals/src/main/java/org/craftedsw/romannumerals/RomanNumeralGenerator.java +++ b/TDD/sandromancuso/romannumerals/src/main/java/org/craftedsw/romannumerals/RomanNumeralGenerator.java @@ -4,8 +4,9 @@ public class RomanNumeralGenerator { public static String romanFor(int decimal) { String roman = ""; - if (decimal == 5) { - return "V"; + if (decimal >= 5) { + roman += "V"; + decimal -= 5; } for (int i = 0; i < decimal; i++) { roman += "I"; diff --git a/TDD/sandromancuso/romannumerals/src/test/java/org/craftedsw/romannumerals/RomanNumeralsGeneratorShould.java b/TDD/sandromancuso/romannumerals/src/test/java/org/craftedsw/romannumerals/RomanNumeralsGeneratorShould.java index c741117..ed9e0d8 100644 --- a/TDD/sandromancuso/romannumerals/src/test/java/org/craftedsw/romannumerals/RomanNumeralsGeneratorShould.java +++ b/TDD/sandromancuso/romannumerals/src/test/java/org/craftedsw/romannumerals/RomanNumeralsGeneratorShould.java @@ -22,6 +22,7 @@ public class RomanNumeralsGeneratorShould { // going to be more complicated and we do not already have // the pattern to extract the algorithm for the IV number. assertThat(romanFor(5), is("V")); + assertThat(romanFor(7), is("VII")); } }