From a2dcf84c49833b42dfa10fc7ec5cf9c0c3ef173c Mon Sep 17 00:00:00 2001 From: Thomas Papendieck Date: Wed, 28 Nov 2018 17:50:25 +0100 Subject: [PATCH] quick and dirty implementation, mostly generated by IDE --- .../de/edu/hsfulda/ciip/tdd/BownlingCalculator.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 a582e3d..3166e56 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 @@ -1,10 +1,17 @@ package de.edu.hsfulda.ciip.tdd; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class BownlingCalculator { public int evaluate(String listOfThrows) { - // TODO Auto-generated method stub - return 0; + Matcher matcher = Pattern.compile("\\d").matcher(listOfThrows); + int sum =0; + while (matcher.find()) { + sum+=Integer.parseInt(matcher.group()); + } + return sum; } }