diff --git a/TDD-pure-function/src/main/java/de/edu/hsfulda/ciip/tdd/BownlingCalculator.java b/TDD-pure-function/src/main/java/de/edu/hsfulda/ciip/tdd/BownlingCalculator.java index 8908da4..c732390 100644 --- a/TDD-pure-function/src/main/java/de/edu/hsfulda/ciip/tdd/BownlingCalculator.java +++ b/TDD-pure-function/src/main/java/de/edu/hsfulda/ciip/tdd/BownlingCalculator.java @@ -6,10 +6,14 @@ import java.util.regex.Pattern; public class BownlingCalculator { public int evaluate(String listOfThrows) { - int sum =0; + int sum = 0; Matcher singleDigit = Pattern.compile("\\d").matcher(listOfThrows); while (singleDigit.find()) { - sum+=Integer.parseInt(singleDigit.group()); + sum += Integer.parseInt(singleDigit.group()); + } + singleDigit = Pattern.compile("(\\d)/ (\\d)").matcher(listOfThrows); + while (singleDigit.find()) { + sum += 10 - Integer.parseInt(singleDigit.group(1)) + Integer.parseInt(singleDigit.group(2)); } return sum; }