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

Assignment: Write algorithms and programs to implement a simulation of a deck of

ID: 3731614 • Letter: A

Question

Assignment: Write algorithms and programs to implement a simulation of a deck of cards for a card game - stud poker. Your simulation will use structures to represent each card, not a simple primitive type — your choice on how to represent the deck and hands; but hands should be separate from the deck. This implementation will only allow from 1-7 players (instead of 1-13) and ONLY 5 cards per hand (instead of 1-13) . During your validation, any integer value entered for the cards per hand must be changed to 5. Additionally, the hands will be sorted (by rank value) and displayed after sorting. The hands will then be assigned their poker rank (one pair, two pair, flush, etc.). Finally, one (or more) of the hands will be designated as “the winner”, based upon the poker hand ranking.

Explanation / Answer

  

algorithm

const int START = 0; const int PREVIOUS = -1; int player; for (player = 0; player < players; player++) { int i; // index of outer loop int j; // index of inner loop for (i = cardsPerHand + PREVIOUS; i > START; i--) { int maxIndex = 0; for (j = 1; j <= i; j++) { if (hands[maxIndex][player].rank < hands[j][player].rank) { maxIndex = j; } // end if } // end for Card tempCard = hands[i][player]; hands[i][player] = hands[maxIndex][player]; hands[maxIndex][player] = tempCard; } // end for } // end for */ /* insertion sort const int START = 0; int previous; int player; for (player = 0; player < players; player++) { int i; // index of outer loop int j; // index of inner loop for (i = 1; i < cardsPerHand; i++) { Card tempCard = hands[i][player]; for (j = i; j > START; j--) { previous = j - 1; if (tempCard.rank >= hands[previous][player].rank) { break; } else { hands[j][player] = hands[previous][player]; } // end if else } // end for hands[j][player] = tempCard; } // end for } // end for */
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