|
help
here is my code ...could u please solve this issue. i have a problem while using the deck.length.
public static void cardList(int numHands,int cardsPerHand){
List<String> deck,hand;
//52-card deck
String[]suit=new String[]{"S","H","D","C"};
String[] rank=new String[]{"A","2","3","4","5","6","7","8","9","10","J","Q", "K"};
deck=new ArrayList<String>();
for(int i=0;i<deck.length; i++){
for(int j=i;j<deck.length;j++){
deck.add(rank[i]+"-"+suit[j]);
}
}
Collections.shuffle(deck);//shuffles the heap of the crads
//dealing the cards
for(int i=0;i<numHands;i++){
hand=deck.subList(deck.size()-cardsPerHand,deck.size());
System.out.println(hand);
//hand.clear();//removes the sub-list from the list
}}}
|