@Test public void dealHands() { Deque<Card> jdkShuffled = this.jdkDeck.shuffle(new Random(1)); List<Set<Card>> jdkHands = this.jdkDeck.dealHands(jdkShuffled, 5, 5); Assert.assertEquals(5, jdkHands.size()); Assert.assertTrue(Iterate.allSatisfy(jdkHands, each -> each.size() == 5)); Assert.assertEquals(27, jdkShuffled.size()); }
public List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, int cardsPerHand) { List<Set<Card>> result = new ArrayList<>(); for (int i = 0; i < hands; i++) { result.add(this.deal(shuffled, cardsPerHand)); } return Collections.unmodifiableList(result); }
JDKImperativeDeckOfCardsAsSortedSet { public List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, int cardsPerHand) { List<Set<Card>> result = new ArrayList<>(); for (int i = 0; i < hands; i++) { result.add(this.deal(shuffled, cardsPerHand)); } return Collections.unmodifiableList(result); } }
JDKImperativeDeckOfCardsAsSortedSet { public List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, int cardsPerHand) { List<Set<Card>> result = new ArrayList<>(); for (int i = 0; i < hands; i++) { result.add(this.deal(shuffled, cardsPerHand)); } return Collections.unmodifiableList(result); } JDKImperativeDeckOfCardsAsSortedSet(); }
JDKImperativeDeckOfCardsAsSortedSet { public List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, int cardsPerHand) { List<Set<Card>> result = new ArrayList<>(); for (int i = 0; i < hands; i++) { result.add(this.deal(shuffled, cardsPerHand)); } return Collections.unmodifiableList(result); } JDKImperativeDeckOfCardsAsSortedSet(); 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); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit(); }
JDKImperativeDeckOfCardsAsSortedSet { public List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, int cardsPerHand) { List<Set<Card>> result = new ArrayList<>(); for (int i = 0; i < hands; i++) { result.add(this.deal(shuffled, cardsPerHand)); } return Collections.unmodifiableList(result); } JDKImperativeDeckOfCardsAsSortedSet(); 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); SortedSet<Card> diamonds(); SortedSet<Card> hearts(); SortedSet<Card> spades(); SortedSet<Card> clubs(); Map<Suit, Long> countsBySuit(); Map<Rank, Long> countsByRank(); SortedSet<Card> getCards(); Map<Suit, SortedSet<Card>> getCardsBySuit();  }