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

Fixed syntax toi match concention of streams

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