@Test public void countsByRank() { Assert.assertEquals(Long.valueOf(4), this.jdkDeck.countsByRank().get(Rank.TEN)); }
public Map<Rank, Long> countsByRank() { var result = new HashMap<Rank, Long>(); for (var card : this.cards) { var rank = card.rank(); var value = result.computeIfAbsent(rank, r -> Long.valueOf(0)); result.put(rank, value + 1); } return result; }
JDKImperativeDeckOfCardsAsList { public Map<Rank, Long> countsByRank() { var result = new HashMap<Rank, Long>(); for (var card : this.cards) { var rank = card.rank(); var value = result.computeIfAbsent(rank, r -> Long.valueOf(0)); result.put(rank, value + 1); } return result; } }
JDKImperativeDeckOfCardsAsList { public Map<Rank, Long> countsByRank() { var result = new HashMap<Rank, Long>(); for (var card : this.cards) { var rank = card.rank(); var value = result.computeIfAbsent(rank, r -> Long.valueOf(0)); result.put(rank, value + 1); } return result; } JDKImperativeDeckOfCardsAsList(); }
JDKImperativeDeckOfCardsAsList { public Map<Rank, Long> countsByRank() { var result = new HashMap<Rank, Long>(); for (var card : this.cards) { var rank = card.rank(); var value = result.computeIfAbsent(rank, r -> Long.valueOf(0)); result.put(rank, value + 1); } return result; } JDKImperativeDeckOfCardsAsList(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, int cardsPerHand); List<Card> diamonds(); List<Card> hearts(); List<Card> spades(); List<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); List<Card> getCards(); Map<Suit, List<Card>> getCardsBySuit(); }
JDKImperativeDeckOfCardsAsList { public Map<Rank, Long> countsByRank() { var result = new HashMap<Rank, Long>(); for (var card : this.cards) { var rank = card.rank(); var value = result.computeIfAbsent(rank, r -> Long.valueOf(0)); result.put(rank, value + 1); } return result; } JDKImperativeDeckOfCardsAsList(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, int cardsPerHand); List<Card> diamonds(); List<Card> hearts(); List<Card> spades(); List<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); List<Card> getCards(); Map<Suit, List<Card>> getCardsBySuit();  }