Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .besouro/20160930153322118/actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FileOpenedAction 1475238802348 RomanNumerals.java 121 1 1 0
RefactoringAction 1475238944009 TestRomanNumerals.java ADD void test()/2 METHOD
RefactoringAction 1475238979562 TestRomanNumerals.java RENAME test()/2=>void i() METHOD
RefactoringAction 1475238981106 TestRomanNumerals.java RENAME i()=>void ixcm() METHOD
RefactoringAction 1475239059902 TestRomanNumerals.java RENAME ixcm()=>void ixcmCan() METHOD
RefactoringAction 1475239062476 TestRomanNumerals.java RENAME ixcmCan()=>void ixcmCanBe() METHOD
RefactoringAction 1475239065066 TestRomanNumerals.java RENAME ixcmCanBe()=>void ixcmCanBeRepated() METHOD
RefactoringAction 1475239067140 TestRomanNumerals.java RENAME ixcmCanBeRepated()=>void ixcmCanBeRepated3() METHOD
RefactoringAction 1475239076953 TestRomanNumerals.java ADD void test()/2 METHOD
RefactoringAction 1475239086219 TestRomanNumerals.java RENAME test()/2=>void vld() METHOD
RefactoringAction 1475239088809 TestRomanNumerals.java RENAME vld()=>void vldCannot() METHOD
RefactoringAction 1475239092943 TestRomanNumerals.java RENAME vldCannot()=>void vldCannotBeRepeta() METHOD
RefactoringAction 1475239096562 TestRomanNumerals.java RENAME vldCannotBeRepeta()=>void vldCannotBeRepea() METHOD
RefactoringAction 1475239097607 TestRomanNumerals.java RENAME vldCannotBeRepea()=>void vldCannotBeRepeated() METHOD
RefactoringAction 1475239107919 TestRomanNumerals.java RENAME ixcmCanBeRepated3()=>void ixcmcanBeRepated3() METHOD
RefactoringAction 1475239112037 TestRomanNumerals.java RENAME ixcmcanBeRepated3()=>void IXCMcanBeRepated3() METHOD
RefactoringAction 1475239116686 TestRomanNumerals.java RENAME vldCannotBeRepeated()=>void vldcannotBeRepeated() METHOD
RefactoringAction 1475239119276 TestRomanNumerals.java RENAME vldcannotBeRepeated()=>void cannotBeRepeated() METHOD
RefactoringAction 1475239121351 TestRomanNumerals.java RENAME cannotBeRepeated()=>void VLDcannotBeRepeated() METHOD
RefactoringAction 1475239302610 TestRomanNumerals.java RENAME test()=>void plus1() METHOD
RefactoringAction 1475239303638 TestRomanNumerals.java RENAME plus1()=>void plus1is() METHOD
RefactoringAction 1475239304662 TestRomanNumerals.java RENAME plus1is()=>void plus1isTwo() METHOD
RefactoringAction 1475239317701 TestRomanNumerals.java RENAME plus1isTwo()=>void test() METHOD
RefactoringAction 1475239372220 TestRomanNumerals.java RENAME test()=>void testAddition() METHOD
RefactoringAction 1475240787783 TestRomanNumerals.java RENAME testAddition()=>void test() METHOD
RefactoringAction 1475240790872 TestRomanNumerals.java RENAME test()=>void testIs() METHOD
RefactoringAction 1475240791902 TestRomanNumerals.java RENAME testIs()=>void testIs1() METHOD
EditAction 1475241849305 RomanNumerals.java 451 1 0 0
CompilationAction 1475241849586 RomanNumerals.java
CompilationAction 1475241849586 RomanNumerals.java
EditAction 1475242214862 RomanNumerals.java 545 1 0 0
CompilationAction 1475242214940 RomanNumerals.java
CompilationAction 1475242214940 RomanNumerals.java
EditAction 1475242412266 TestRomanNumerals.java 319 3 2 0
CompilationAction 1475242412360 TestRomanNumerals.java
CompilationAction 1475242412360 TestRomanNumerals.java
CompilationAction 1475242412360 TestRomanNumerals.java
UnitTestCaseAction 1475242417682 TestRomanNumerals.java FAIL
UnitTestSessionAction 1475242417682 TestRomanNumerals.java FAIL
EditAction 1475242507102 RomanNumerals.java 545 1 0 0
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
67 changes: 63 additions & 4 deletions src/RomanNumerals.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,67 @@

public class RomanNumerals {
public int convertToInteger(String romanNum) {
// To be Implemented
return 0;

int arabicNum = 0;

String roman = romanNum.toUpperCase();
for(int x = 0;x<romanNum.length();x++)
{
char convertToDecimal = romanNum.charAt(x);

switch (convertToDecimal) {
case 'M':
arabicNum += 1000;
break;

case 'D':
arabicNum += 500;
break;

case 'C':
arabicNum += 100;
break;

case 'L':
arabicNum += 50;
break;

case 'X':
arabicNum += 10;
break;

case 'V':
arabicNum += 5;
break;

case 'I':
arabicNum += 1;
break;
}
}
if (roman.contains("IV"))
{
arabicNum-=2;
}
if (roman.contains("IX"))
{
arabicNum-=2;
}
if (roman.contains("XL"))
{
arabicNum-=10;
}
if (roman.contains("XC"))
{
arabicNum-=10;
}
if (roman.contains("CD"))
{
arabicNum-=100;
}
if (roman.contains("CM"))
{
arabicNum-=100;
}
return arabicNum;
}
}
}
15 changes: 14 additions & 1 deletion tests/TestRomanNumerals.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@
import org.junit.Test;

public class TestRomanNumerals {

private static void assertRomanNumeralsEquals(String romanNum, int arabNum) {
//assertThat(roman, is(RomanNumerals.convert(arabNum)));
}

@Test
public void test() {
public void testIs1() {
assertRomanNumeralsEquals("I", 200);
}

@Test
public void IXCMcanBeRepated3() {
fail("Not yet implemented");
}

@Test
public void VLDcannotBeRepeated() {
fail("Not yet implemented");
}
}