Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Initializing a deck of cards using two strings

$
0
0
Hello, my professor wants me to initiate a deck of cards using two strings:

static String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
static String[] ranks = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"};

I've never done anything like that before. If it was me, I would just specify

deck[52] = {'h2', 'h3', 'h4',}; //etc.

and spell out the elements of the array. Then I could do shuffling and all that. However, he has two strings - suits and ranks - and I'm not sure how to use those to initialize the deck.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>