Skip to content
Snippets Groups Projects
Commit a7526bbc authored by Scott Langum Du Plessis's avatar Scott Langum Du Plessis
Browse files

Added findHearts method to HandsOfCards

parent e19bcf5e
No related branches found
No related tags found
1 merge request!3Added HandOfCard class to
......@@ -24,4 +24,18 @@ public class HandOfCards {
mapToInt(PlayingCard::getFace).
sum();
}
public String findHearts() {
StringBuilder sb = new StringBuilder();
hand.stream().
map(PlayingCard::getAsString).
filter(s -> s.charAt(0) == 'H').
forEach(sb::append);
if (sb.isEmpty()) {
return "No hearts";
}
return sb.toString();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment