diff --git a/.besouro/20160930163040936/actions.txt b/.besouro/20160930163040936/actions.txt new file mode 100644 index 0000000..690b973 --- /dev/null +++ b/.besouro/20160930163040936/actions.txt @@ -0,0 +1,53 @@ +FileOpenedAction 1475242241337 TestRomanNumerals.java 305 1 4 0 +UnitTestCaseAction 1475242245986 TestRomanNumerals.java FAIL +UnitTestSessionAction 1475242245988 TestRomanNumerals.java FAIL +EditAction 1475242279768 TestRomanNumerals.java 282 1 3 1 +UnitTestCaseAction 1475242281329 TestRomanNumerals.java OK +UnitTestSessionAction 1475242281331 TestRomanNumerals.java OK +EditAction 1475242292287 TestRomanNumerals.java 282 1 3 1 +UnitTestCaseAction 1475242293877 TestRomanNumerals.java FAIL +UnitTestSessionAction 1475242293878 TestRomanNumerals.java FAIL +EditAction 1475242304653 TestRomanNumerals.java 282 1 3 1 +UnitTestCaseAction 1475242306104 TestRomanNumerals.java OK +UnitTestSessionAction 1475242306105 TestRomanNumerals.java OK +EditAction 1475242788919 RomanNumerals.java 652 2 3 0 +UnitTestCaseAction 1475242790530 TestRomanNumerals.java OK +UnitTestSessionAction 1475242790531 TestRomanNumerals.java OK +EditAction 1475242801310 TestRomanNumerals.java 282 1 3 1 +UnitTestCaseAction 1475242802842 TestRomanNumerals.java OK +UnitTestSessionAction 1475242802843 TestRomanNumerals.java OK +EditAction 1475242830503 TestRomanNumerals.java 283 1 3 1 +UnitTestCaseAction 1475242831929 TestRomanNumerals.java OK +UnitTestSessionAction 1475242831930 TestRomanNumerals.java OK +EditAction 1475242847443 TestRomanNumerals.java 282 1 3 1 +UnitTestCaseAction 1475242848954 TestRomanNumerals.java OK +UnitTestSessionAction 1475242848955 TestRomanNumerals.java OK +EditAction 1475242854557 TestRomanNumerals.java 283 1 3 1 +UnitTestCaseAction 1475242855977 TestRomanNumerals.java FAIL +UnitTestSessionAction 1475242855979 TestRomanNumerals.java FAIL +RefactoringAction 1475243138983 RomanNumerals.java ADD static int romanConvert(String) METHOD +EditAction 1475243255981 TestRomanNumerals.java 279 1 3 1 +CompilationAction 1475243257264 TestRomanNumerals.java +EditAction 1475243257327 RomanNumerals.java 1617 3 14 0 +UnitTestCaseAction 1475243258837 TestRomanNumerals.java FAIL +UnitTestSessionAction 1475243258838 TestRomanNumerals.java FAIL +EditAction 1475243275960 TestRomanNumerals.java 279 1 3 1 +UnitTestCaseAction 1475243277522 TestRomanNumerals.java OK +UnitTestSessionAction 1475243277523 TestRomanNumerals.java OK +EditAction 1475243543117 TestRomanNumerals.java 278 1 3 1 +EditAction 1475243544409 RomanNumerals.java 1617 3 14 0 +UnitTestCaseAction 1475243545850 TestRomanNumerals.java FAIL +UnitTestSessionAction 1475243545851 TestRomanNumerals.java FAIL +EditAction 1475243554185 TestRomanNumerals.java 278 1 3 1 +UnitTestCaseAction 1475243555673 TestRomanNumerals.java OK +UnitTestSessionAction 1475243555675 TestRomanNumerals.java OK +RefactoringAction 1475243567170 RomanNumerals.java REMOVE convertToInteger(String) METHOD +RefactoringAction 1475243572183 RomanNumerals.java RENAME romanConvert(String)=>int convertToInteger(String) METHOD +EditAction 1475243655382 RomanNumerals.java 935 2 10 0 +CompilationAction 1475243656692 TestRomanNumerals.java +CompilationAction 1475243679108 TestRomanNumerals.java +UnitTestCaseAction 1475243682249 TestRomanNumerals.java OK +UnitTestSessionAction 1475243682250 TestRomanNumerals.java OK +EditAction 1475243704671 TestRomanNumerals.java 283 1 3 1 +UnitTestCaseAction 1475243706091 TestRomanNumerals.java OK +UnitTestSessionAction 1475243706091 TestRomanNumerals.java OK diff --git a/.besouro/20160930163040936/besouroEpisodes.txt b/.besouro/20160930163040936/besouroEpisodes.txt new file mode 100644 index 0000000..0442dbe --- /dev/null +++ b/.besouro/20160930163040936/besouroEpisodes.txt @@ -0,0 +1,10 @@ +1475242281331 test-addition 1 39 true +1475242306105 regression 2 13 true +1475242790531 regression 1 1 true +1475242802843 regression 1 1 true +1475242831930 regression 1 1 true +1475242848955 regression 1 1 true +1475243277523 production 3 422 false +1475243555675 regression 2 12 true +1475243682250 refactoring 2A 115 true +1475243706091 regression 1 1 true diff --git a/.besouro/20160930163040936/disagreements.txt b/.besouro/20160930163040936/disagreements.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20160930163040936/randomHeuristicEpisodes.txt b/.besouro/20160930163040936/randomHeuristicEpisodes.txt new file mode 100644 index 0000000..dbda34c --- /dev/null +++ b/.besouro/20160930163040936/randomHeuristicEpisodes.txt @@ -0,0 +1,10 @@ +1475242281331 test-addition 1 39 true +1475242306105 regression 2 13 false +1475242790531 regression 1 1 true +1475242802843 regression 1 1 false +1475242831930 regression 1 1 true +1475242848955 regression 1 1 true +1475243277523 production 3 422 true +1475243555675 regression 2 12 true +1475243682250 refactoring 2A 115 true +1475243706091 regression 1 1 true diff --git a/.besouro/20160930163040936/userComments.txt b/.besouro/20160930163040936/userComments.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20160930163040936/zorroEpisodes.txt b/.besouro/20160930163040936/zorroEpisodes.txt new file mode 100644 index 0000000..d580a2f --- /dev/null +++ b/.besouro/20160930163040936/zorroEpisodes.txt @@ -0,0 +1,10 @@ +1475242281331 test-addition 1 39 false +1475242306105 regression 2 24 false +1475242790531 regression 1 484 false +1475242802843 regression 1 12 false +1475242831930 regression 1 29 false +1475242848955 regression 1 17 false +1475243277523 production 3 428 false +1475243555675 regression 2 278 false +1475243682250 refactoring 2A 126 false +1475243706091 regression 1 23 false diff --git a/src/RomanNumerals.java b/src/RomanNumerals.java index 20904f0..f5409a3 100644 --- a/src/RomanNumerals.java +++ b/src/RomanNumerals.java @@ -1,8 +1,66 @@ public class RomanNumerals { - public int convertToInteger(String romanNum) { - // To be Implemented - return 0; + + public RomanNumerals() { + } + + public int convertToInteger(String roman) { + + int decimal = 0; + + roman = roman.toUpperCase(); + for (int i = 0; i < roman.length(); i++) { + int convertToDecimal = roman.charAt(i); + + switch (convertToDecimal) { + case 'M': + decimal += 1000; + break; + + case 'D': + decimal += 500; + break; + + case 'C': + decimal += 100; + break; + + case 'L': + decimal += 50; + break; + + case 'X': + decimal += 10; + break; + + case 'V': + decimal += 5; + break; + + case 'I': + decimal += 1; + break; + } + } + if (roman.contains("IV")) { + decimal -= 2; + } + if (roman.contains("IX")) { + decimal -= 2; + } + if (roman.contains("XL")) { + decimal -= 10; + } + if (roman.contains("XC")) { + decimal -= 10; + } + if (roman.contains("CD")) { + decimal -= 100; + } + if (roman.contains("CM")) { + decimal -= 100; + } + return decimal; } } diff --git a/tests/TestRomanNumerals.java b/tests/TestRomanNumerals.java index 5d1de75..a57e6a4 100644 --- a/tests/TestRomanNumerals.java +++ b/tests/TestRomanNumerals.java @@ -6,7 +6,16 @@ public class TestRomanNumerals { @Test public void test() { - fail("Not yet implemented"); + //fail("Not yet implemented"); + + RomanNumerals obj = new RomanNumerals(); + int num = obj.convertToInteger("l"); + + assertEquals("", 50, num); + + + + } }