You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
400 B
13 lines
400 B
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
public class BowlingGameCalculator {
|
|
public int score(String playerResult) {
|
|
Matcher singleDigit = Pattern.compile("\\d").matcher(playerResult);
|
|
int playerScore = 0;
|
|
while (singleDigit.find()) {
|
|
playerScore += Integer.parseInt(singleDigit.group());
|
|
}
|
|
return playerScore;
|
|
}
|
|
}
|