From 15794a4a28a2c07f24dd4cc950dcfa5d8d7cdec0 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 27 Nov 2016 17:49:42 +0100 Subject: [PATCH] Writing test for VII --- .../main/java/org/craftedsw/romannumerals/RomanNumeralGenerator.java | 5 +++-- .../org/craftedsw/romannumerals/RomanNumeralsGeneratorShould.java | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) 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")); } } -- 2.1.4