Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help to finish this program please. this is the problem and some of the c

ID: 3623208 • Letter: I

Question

I need help to finish this program please. this is the problem and some of the code that I've started.

Your program will implement the preparation routines used in a card game played among four players. First, the program shuffles a deck of cards, and then it deals the card to each of the four players one at a time in clockwise rotation. After all cards are dealt to the players the program organizes the cards in each player’s hand by sorting their cards by suit. Then the program will display each player’s cards.
Requirement:
Your program should have the following routines/functions:
1. FormCards : creates the deck of cards. The deck of cards should be represented as an array of structs. The size of the array is 52. Each card is described by its suit, value, and points in game. For suit, create an enumeration type called “CardSuitType” that has the four values: DIAMOD, CLUB, HEART, SPADE. For card points in game, all the cards of HEART suit have point: each HEART card of less than 10 face value has 5 points; HEART of 10, Jack, Queen, and King each has 10 point. In addition, Queen of SPADE has a point of 100 Jack of CLUB has point of -100. The rest of the cars have 0 point.
2. ShuffleCards: shuffles the cards into random order.

3. DealCards: deals out shuffled cards to the four players. The cards of the four players are stored in a 2-D array of struct typ. The 2D array is of size: 4 rows and 13 columns, where the 4 rows correspond to the 4 players and the 13 columns correspond to the 13 cards each player will receive. That is player one’s cards are in row 1 of the 2D array, player two’s cards are in row 2 of the array, etc..

4. SortCards: cards of one player is sorted by suit.

5. PrintCards: prints the cards of one player in sorted order. The card suit, value and pints in game for each card are displayed. You are encouraged to add routines to make your output graphical.


This is what I have so far.



#include <iostream>
#include <cstring>
#include <cstdlib>
#include <fstream>
using namespace std;

struct card
{
int suit;
int value;
int point;

};

card deckOfCards[52];

enum CardSuitType{DIAMOND,CLUB,HEART,SPADE};

void FormCards();
void ShuffleCard();
void bubbleSort(int arr[], int size);
void PrintCards();

int main()
{
srand(time(0) );


void ShuffleCard(int [],int[])
{
int i, j;
Card temp;

for ( i = 0; i<= 51; i++ ) {
j = rand() % 52;
temp =wDeck[ i ];
wDeck[ i ] = wDeck[ j ];
wDeck[ j ] = temp;
}


void bubbleSort(int arr[], int size)
{
int last = size - 2;
int isChanged = 1;

while (last >= 0 && isChanged)
{
isChanged = 0;

for (int k = 0; k <= last; k++)
if (arr[k] < arr[k+1])
{
swap(arr[k], arr[k+1]);
isChanged = 1;
}
last--;
}
}// end bubbleSort()

void swap(int& x, int& y)
{
int temp;
temp = x;
x = y;
y = temp;
}// end swap()

Explanation / Answer

please rate - thanks

there is no formcards, the deck is randomly generated in shuffle

hope this is good

// example about structures
#include <iostream>
#include <string>
using namespace std;

struct card
{ int Suit;
int value;
int point;
};
enum CardSuitType{DIAMOND,CLUB,HEART,SPADE};
void shuffle(card[] );
void printcard(card[][13],int);
void bubbleSort(card[][13],int);
void dealcards(card[][13],card[]);

int main ()
{ card player[4][13],deck[52];
shuffle(deck);
dealcards(player,deck);
for(int i=0;i<4;i++)
{bubbleSort(player,i);
printcard(player,i);
}
system("pause");
return 0;
}
void bubbleSort(card player[][13],int n)
{int c,d;
card t;
int i;
for(c=0;c<12;c++)
   for(d=c;d<13;d++)
         if(player[n][c].Suit>player[n][d].Suit)
             {t=player[n][c];
             player[n][c]=player[n][d];
             player[n][d]=t;
             }
}
void dealcards(card player[][13],card deck[])
{int i,j,k=0;
for(i=0;i<4;i++)
   for(j=0;j<13;j++)
       player[i][j]=deck[k++];
return;
}       
void printcard(card name[][13],int n)
{string suit[4]={"diamonds","clubs","hearts","spades"};
string card[13]={"ace","2","3","4","5","6","7","8","9","10","jack","queen","king"};
cout<<"Player "<<n+1<<" hand: ";
cout<<"Card points Suit ";
for(int i=0;i<13;i++)
     cout <<card[name[n][i].value]<<" "
           <<name[n][i].point<<" "<< suit[name[n][i].Suit]<<endl;
cout<<endl<<endl;
}
void shuffle(card deck[])
{int i,j,num,type;
bool cards[4][13];

for(i=0;i<4;i++)
   for(j=0;j<13;j++)
      cards[i][j]=false;
    
for(i=0;i<52;i++)
       {do
           {num=rand()%13;
            type=rand()%4;
            }while(cards[type][num]);
         deck[i].Suit=type;
         deck[i].value=num;
         deck[i].point=0;
         if(type==CLUB)
                {if(num==10)
                      deck[i].point=-100;
                 }   
          else if(type==HEART)
              {if(num<9)
                   deck[i].point=5;
              else
                   deck[i].point=10;
                   }
          if(type==SPADE)
               if(num==11)
                     deck[i].point=100;
              
         cards[type][num]=true;
         }
return;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote