Skip to content

Commit

Permalink
Test 2.2 PASSED - Numeros Separados por Coma
Browse files Browse the repository at this point in the history
  • Loading branch information
IkerCelorrio committed Oct 1, 2011
1 parent 61b4f82 commit d5b5697
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ikercelorrio/java/StringCalculator/src/StringCalculator.java
Expand Up @@ -12,6 +12,10 @@ public int Add(String numbers)
{
if (numbers.isEmpty())
return 0;
return Integer.parseInt(numbers);
if (numbers.indexOf(',') == -1)
return Integer.parseInt(numbers);

String[] numArray = numbers.split(",");
return Integer.parseInt(numArray[0]) + Integer.parseInt(numArray[1]);
}
}
Expand Up @@ -52,4 +52,10 @@ public void NumeroSumaNumero()
assertEquals(1, calc.Add("1"));
assertEquals(2, calc.Add("2"));
}

@Test
public void NumerosSerparadosPorComas()
{
assertEquals(3, calc.Add("1,2"));
}
}

0 comments on commit d5b5697

Please sign in to comment.