|
@ -6,10 +6,10 @@ import java.util.regex.Pattern; |
|
|
public class BownlingCalculator { |
|
|
public class BownlingCalculator { |
|
|
|
|
|
|
|
|
public int evaluate(String listOfThrows) { |
|
|
public int evaluate(String listOfThrows) { |
|
|
Matcher matcher = Pattern.compile("\\d").matcher(listOfThrows); |
|
|
|
|
|
int sum =0; |
|
|
int sum =0; |
|
|
while (matcher.find()) { |
|
|
|
|
|
sum+=Integer.parseInt(matcher.group()); |
|
|
|
|
|
|
|
|
Matcher singleDigit = Pattern.compile("\\d").matcher(listOfThrows); |
|
|
|
|
|
while (singleDigit.find()) { |
|
|
|
|
|
sum+=Integer.parseInt(singleDigit.group()); |
|
|
} |
|
|
} |
|
|
return sum; |
|
|
return sum; |
|
|
} |
|
|
} |
|
|