001package enumeration2;
002
003import java.util.ArrayList;
004import java.util.Collections;
005import java.util.List;
006
007public class Main {
008        private Main() {}
009        public static void main(String args[]) {
010                int numHands = Integer.parseInt(args[0]);
011                int cardsPerHand = Integer.parseInt(args[1]);
012                List<Card> deck  = Card.newDeck();
013                Collections.shuffle(deck);
014                for (int i=0; i < numHands; i++)
015                        System.out.println(deal(deck, cardsPerHand));
016        }
017
018        public static List<Card> deal(List<Card> deck, int n) {
019                int deckSize = deck.size();
020                List<Card> handView = deck.subList(deckSize-n, deckSize);
021                List<Card> hand = new ArrayList<Card>(handView);
022                handView.clear();
023                return hand;
024        }
025}