Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming This is what I have so far #include #include #include void shuffle(int deck[][13]); void deal(int deck[][13], int hand1[][2], int hand2[][2],char *suit[], char *face[],

C Programming

image text in transcribed

This is what I have so far

#include

#include

#include

void shuffle(int deck[][13]); void deal(int deck[][13], int hand1[][2], int hand2[][2],char *suit[], char *face[], int x); int pair(int hand[][2], char *suit[], char *face[], int x); int threeofAkind(int hand[][2], char *suit[], char *face[], int x); int fourOfAKind(int hand[][2], char *suit[], char *face[], int x);; int straightHand(int hand[][2], char *suit[], char *face[], int x); int flushHand(int hand[][2], char *suit[], char *face[], int x); void compare(int hand1[][2], int hand2[][2]); void rearrangeAce(int hand[][2]); void rearrange(int deck[][13], char *suit[], char *face[], int hand[][2], int c, int p); void replace(int deck[][13], int hand2[][2], char *suit[], char *face[], int x);

int main(void) { char *suit[ 4 ] = { "Hearts", "Diamonds", "Clubs", "Spades" }; char *face[ 13 ] = { "Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" }; int deck[ 4 ][ 13 ] = { 0 }; int hand1[5][2] = {0}; int hand2[5][2] = {0}; int p1, t1, f1, s1, fH1, p2, t2, f2, s2, fH2; srand( time( NULL ) );

shuffle( deck ); deal( deck, hand1, hand2, suit, face, 1); p1 = pair(hand1, suit, face,1); t1 = threeOfAKind(hand1,suit,face,1); f1 = fourOfAKind(hand1,suit,face,1); s1 = straightHand(hand1,suit,face,1); fH1 = flushHand(hand1,suit,face,1); p2 = pair(hand2,suit,face,1); t2 = threeofAkind(hand2,suit,face,1); f2 = fourOfAKind(hand2,suit,face,1); s2 = straightHand(hand2,suit,face,1); fH2 = flushHand(hand2,suit,face,1);

if(p2 == 0 && t2 == 0 && f2 == 0 && s2 ==0 && fH2 == 0){ int temp; int pass, comp; for(pass =1; pass hand2[comp+1][1]){ temp = hand2[comp][1]; hand2[comp][1] = hand2[comp+1][1]; hand2[comp+1][1] = temp; } } } if(hand2[0][1] == 0){ rearrangeAce(hand2); printf(" The Dealer replaced 3 cards"); replace(deck, hand2, suit, face,3 ); }else{ printf(" The Dealer replaces 3 cards"); replace(deck, hand2, suit, face, 3); } p2 = pair(hand2,suit,face,2); t2 = threeofAkind(hand2,suit,face,2); f2 = fourOfAKind(hand2,suit,face,2); s2 = straightHand(hand2,suit,face,2); fH2 = flushHand(hand2,suit,face,2);

}else if(p2 != 0 && t2 == 0 && f2 == 0 && s2 == 0 && fH2 == 0){ printf(" The Dealer replaces 3 cards"); rearrange(deck, suit, face, hand2, p2, 3); p2 = pair(hand2,suit,face,2); t2 = threeofAkind(hand2,suit,face,2); f2 = fourOfAKind(hand2,suit,face,2); s2 = straightHand(hand2,suit,face,2); fH2 = flushHand(hand2,suit,face,2); }else if(p2 != 0 && f2 == 0 && s2 == 0 && fH2 == 0){ printf(" The Dealer replaces 2 cards"); rearrange(deck, suit, face, hand2, p2, 2); p2 = pair(hand2,suit,face,2); t2 = threeofAkind(hand2,suit,face,2); f2 = fourOfAKind(hand2,suit,face,2); s2 = straightHand(hand2,suit,face,2); fH2 = flushHand(hand2,suit,face,2); }else if(p2 == 0 && t2 == 0 && f2 != 0 && s2 == 0 && fH2 == 0){ printf(" The Dealer replaces 1 cards"); rearrange(deck, suit, face, hand2, p2, 1); p2 = pair(hand2,suit,face,2); t2 = threeofAkind(hand2,suit,face,2); f2 = fourOfAKind(hand2,suit,face,2); s2 = straightHand(hand2,suit,face,2); fH2 = flushHand(hand2,suit,face,2); } if(fH1 == fH2){ if(s1 == s2){ if(f1 == f2){ if(t1 == t2){ if(p1 == p2){ compare(hand1, hand2); }else{ if(p1 > p2) printf("Player Wins!"); else printf("Dealer Wins"); } }else{ if(t1 > t2) printf("Player Wins!"); else printf("Dealer Wins"); } }else{ if(f1 > f2) printf("Player Wins!"); else printf("Dealer Wins"); } }else{ if(s1 > s2) printf("Player Wins!"); else printf("Dealer Wins"); } }else{ if(fH1 > fH2) printf("Player Wins!"); else printf("Dealer Wins"); } int row, col; int x;

for(x = 0; x

}

}

void shuffle( int wDeck[][ 13 ] ) { int row, column, card;

for ( card = 1; card

wDeck[ row ][ column ] = card; } } void deal(int deck[][13], int hand1[][2], int hand2[][2], char *suit[], char *face[], int x){ int r = 0; int card; int row; int col;

if(x == 1) printf("Player hand is ");

for(card = 1; card

for(card = 6; card

void replace(int deck[][13], int hand[][2], char *suit[], char *face[], int count){ int r, card = 0; row, col; r = 0; for(card = 11; card

void rearrange(int deck[][13], char *suit[], char *face[], int hand[][2], int cn, int n){ int temp[5][2] = {0}; int r = 4, i , j; for(i = 4; i>= 0; i--){ for(j = 0; j

If my code is bad then help me use a different solution. Please due by tonight and completely stuck.

Write a poker game simulation using a structure and strings to define the cards as shown below (Fig. 10.3). Then write the following functions needed for a poker game. a. Determine whether the hand contains a pair. b. Determine whether the hand contains two pairs. c. Determine whether the hand contains three of a kind (e.g., three jacks). d. Determine whether the hand contains four of a kind (e.g., four aces). e. Determine whether the hand contains a flush (i.e., all five cards of the same suit). f. Determine whether the hand contains a straight (i.e., five cards of consecutive face values). Also write a function that deals two five-card poker hands, evaluates each, and determines which is the better hand. Using pass by pointer technique, the function should provide the a- The two hands b- Status of each hand (i.e. contains a pair or two pairs,..) c- Determination of which hand is the better hand The main program should play the poker game 100 times and store the result in an array. Also the same information needs to be stored in a file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago