public static void shuffle_deck(
String[] card_number,
String[] card_name) {
Random generator = new Random();
System.out.println("\nShuffled Deck: ");
for (int i = 0; i < card_number.length; i++) {
for (int j = 0; j < card_name.length; j++) {
int randomIndextoSwap1 = generator.nextInt(card_number.length);
String number_swap = card_number[randomIndextoSwap1];
card_number[randomIndextoSwap1] = card_number[i];
int randomIndexToSwap2 = generator.nextInt(card_name.length);
String suit_swap = card_name[randomIndexToSwap2];
card_name[randomIndexToSwap2] = card_name[j];
System.out.println(card_number[i] + " OF " + card_name[j]);
}
}
vendredi 19 novembre 2021
Generating Unique Random Elements in Java using RANDOM METHOD ALONE in java [closed]
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire