As the topic may explain, I need to figure out if out of the five cards dealt to the player are any of them considered a pair, If there is a pair it would be printed as part of the final JOptionPane to state "You have a pair of [pair]" Is there a way to do this with the way i have the strings set up currently or will they not be recognized as pairs because they would never be the same suit...
thank you for any help.
here is my code right now:
int cardsPerPlayer = 5;
int players = 1;
String[] suit = {" of Spades", " of Diamonds", " of Clubs", " of Hearts"};
String[] face = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
String [] deck = new String[52];
for (int i = 0; i < deck.length; i++){
deck [i] = face[i%13] + suit[i/13];
//System.out.println(deck[i]);
}
for (int i = 0; i <deck.length; i++){
int index = (int) (Math.random()*deck.length);
String temp = deck[i];
deck[i] = deck[index];
deck[index] = temp;
}
for (String u: deck) {
//System.out.println(deck);
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < players * cardsPerPlayer; i++) {
sb.append(deck[i])
.append("\n");
}
JOptionPane.showMessageDialog(null, sb.toString());
}
}