Advertisement
Guest User

Untitled

a guest
May 14th, 2014
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Collections;
  3. import java.util.Scanner;
  4. import java.util.List;
  5. public class RandomHands {
  6.  
  7.     public static void main(String[] args) {
  8.         String clubs = "♣";
  9.         String diamonds = "♦";
  10.         String hearts = "♥";
  11.         String spades = "♠";
  12.         Scanner input = new Scanner(System.in);
  13.         int count = input.nextInt();
  14.         String rank[] = new String[52];
  15.         int counter = 0;
  16.         for (int i = 1; i <= 13; i++) {
  17.             String currentCard = "";
  18.             if(i==1) currentCard = "A";
  19.             else if(i<=10) currentCard = currentCard + i;
  20.             else{
  21.                 switch(i){
  22.                 case 11: currentCard = "J";break;
  23.                 case 12: currentCard = "Q";break;
  24.                 case 13: currentCard = "K";break;
  25.                 }
  26.             }
  27.           rank[counter] = "" + currentCard + clubs;
  28.           rank[counter+1] = "" + currentCard + diamonds;
  29.           rank[counter+2] = "" + currentCard + hearts;
  30.           rank[counter+3]= "" + currentCard + spades;
  31.           counter+=4;
  32.         }
  33.         List<String> cards = Arrays.asList(rank);
  34.         for(int i=0; i<count;i++){
  35.             Collections.shuffle(cards);
  36.             List<String> selectedCards = cards.subList(0, 5);
  37.             System.out.println(selectedCards.toString());
  38.         }
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement