import java.util.*;
public class WarGame {
public static void main(String[] args) {
String deckInitial = "A/D, K/D, Q/D, J/D, 10/D, 9/D, 8/D, 7/D, 6/D, 5/D, 4/D, 3/D, 2/D, A/H, K/H, Q/H, J/H, 10/H, 9/H, 8/H, 7/H, 6/H, 5/H, 4/H, 3/H, 2/H, A/S, K/S, Q/S, J/S, 10/S, 9/S, 8/S, 7/S, 6/S, 5/S, 4/S, 3/S, 2/S, A/C, K/C, Q/C, J/C, 10/C, 9/C, 8/C, 7/C, 6/C, 5/C, 4/C, 3/C, 2/C";
String deckRank = "A/D, A/H, A/S, A/C, K/D, K/H, K/S, K/C, Q/D, Q/H, Q/S, Q/C, J/D, J/H, J/S, J/C, 10/D, 10/H, 10/S, 10/C, 9/D, 9/H, 9/S, 9/C, 8/D, 8/H, 8/S, 8/C, 7/D, 7/H, 7/S, 7/C, 6/D, 6/H, 6/S, 6/C, 5/D, 5/H, 5/S, 5/C, 4/D, 4/H, 4/S, 4/C, 3/D, 3/H, 3/S, 3/C, 2/D, 2/H, 2/S, 2/C";
System.out.println ("Deck of Cards - Initial: " + deckInitial);
HashMap <String, Integer> deck1 = new HashMap <String, Integer> ();
HashMap <String, Integer> rank1 = new HashMap <String, Integer> ();
StringTokenizer str1 = new StringTokenizer (deckInitial, ",");
while (str1.hasMoreTokens()){
for (int i=0; i<52; i++){
deck1.add(str1.nextToken(), (i));
}
}
StringTokenizer str2 = new StringTokenizer (deckRank, ",");
while (str2.hasMoreTokens()){
for (int i=0; i<52; i++){
rank1.add(str2.nextToken(), (i));
}
}
HashMap<String, Integer> rd = new HashMap<String, Integer>();
for (int i=0; i<52; i++){
rd.add(rank1.pop(), (i));
}
//Shuffle
Integer shuffleInput = null;
HashMap<String, Integer> deck2 = new HashMap<String, Integer>();
HashMap<String, Integer> deck3 = new HashMap<String, Integer>();
HashMap<String, Integer> deckFinal = new HashMap<String, Integer>();
Scanner input = new Scanner (System.in);
System.out.print("\nEnter number of Shuffle: ");
if (input.hasNextInt()){
shuffleInput = input.nextInt();
}
while(shuffleInput != 0){
do {
deck2.add(deck1.pop());
}while (deck2.size() != 26);
do {
deck3.add(deck1.pop());
}while (deck3.size() != 26);
do{
deckFinal.add(deck2.pop());
deckFinal.add(deck3.pop());
}while(!deck3.isEmpty() && !deck2.isEmpty());
shuffleInput--;
if(shuffleInput != 0){
deck1 = deckFinal;
}
}
System.out.println("\nDeck of Cards - Shuffled: " + deckFinal);
}
}