It’s going well, I’m working on the first bits of it. Some starting points such as just shuffling and dealing a deck of cards.
This is what I’ve got so far:
//put random numbers in slots
#include iostream
#include ctime
#include cstdlib
#include iomanip
using namespace std;
int main ()
{
const int totalCards = 52;
const int deckRows = 4;
const int deckColumns = 13;
int deck[ deckRows ][ deckColumns ] = { 0 };
char *suite[] = { “Hearts”, “Clubs”, “Diamonds”, “Spades” };
char *face[] = { “Ace”, “Two”, “Three”, “Four”, “Five”, “Six”, “Seven”, “Eight”, “Nine”, “Ten”, “Jack”, “Queen”, “King” };
srand( time( 0 ) );
for( int card = 1; card <= totalCards; card++ ) {
int randrow = rand() % deckRows;
int randcolumn = rand() % deckColumns;
while( deck[randrow][randcolumn] != 0 ) {
randrow = rand() % 4;
randcolumn = rand() % 13;
}
deck[randrow][randcolumn] = card;
}
/*
//print the deck
for( int i = 0; i < deckRows; i++ ) {
for( int j = 0; j < deckColumns; j++ ) {
cout << setw( 5 ) << deck[ i ][ j ] << ” “;
}
cout << endl;
}
//check for wrong numbers
for( int x = 0; x < deckRows; x++ ) {
for( int y = 0; y 52 || deck[ x ][ y ] < 1 ) {
cout << “INVALID NUMBER DETECTED IN LOCATION: ” << x << “, ” << y << endl;
}
}
}
*/
for( int card = 1; card < totalCards; card++ ) {
for( int i = 0; i < deckRows; i++ ) {
for( int j = 0; j < deckColumns; j++ ) {
if( deck[ i ][ j ] == card ) {
cout << face[ j ] << ” of ” << suite[ i ] << endl;
}
}
}
}
}
again, add the indentation yourself!
It essentially shuffles a deck of cards and deals all 52 cards and says what they are in order! If you don’t understand part of the code, just let me know by writing a comment!