I want the answer in Java not in C or other language because

I want the answer in Java not in C++ or other language because I received the answer for this task in C

Task #1 Do the Shuffle

Now that you’ve created a “pseudo” deck of cards that you have stored in an array, now programmatically “shuffle” them in order to create a deck of cards that is randomly sorted. How you accomplish this task is up to you! You must use either the Array or ArrayList for this task.

Solution

public class Deck { private Card[] cards; // array holding all 52 cards private int cardsInDeck; // the current number of cards in the deck public static final int DECK_SIZE = 52; /** * Shuffles the deck (i.e. randomly reorders the cards in the deck). */ public void shuffle() { int newI; Card temp; Random randIndex = new Random(); for (int i = 0; i < cardsInDeck; i++) { // pick a random index between 0 and cardsInDeck - 1 newI = randIndex.nextInt(cardsInDeck); // swap cards[i] and cards[newI] temp = cards[i]; cards[i] = cards[newI]; cards[newI] = temp; } } }
I want the answer in Java not in C++ or other language because I received the answer for this task in C Task #1 Do the Shuffle Now that you’ve created a “pseudo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site