Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program to 1) Create a full deck of 52 cards that are in order. In other words, for each of the four

image text in transcribedimage text in transcribed

Write a C program to 1) Create a full deck of 52 cards that are in order. In other words, for each of the four suits, the cards should be in order from Ace (1) through King (13). each card is consisted of a suit [clubs (+),spades (+),hearts (), or diamonds ()) a face (1(Ace) 10, Jacks (I), Queens (Q), and Kings (K)) To simulate the deck of 52 cards, and each of the hands, your team MUST use a dynamic list of cards with the following struct type typedef struct card_s char suit int face struct card s *next; car Print the deck that you create. 2) Shuffle the deck (52 cards). Note: Your code must have a ShuffleCard) function and should work with any size deck of cards, i.e. shuffling 53 cards, 20 cards or 5 cards. One algorithm that you may use to shuffle the deck. (a) For each card in the deck, get a random number in the range of 0 to 51 to be used as the index of the element to swap that card with, ie if deck[0] holds the Jack of clubs +) and the random number generated was 24, and deck[24] holds the 9 of diamonds(9+), then after the first swap, deck[0] would hold the 9 of diamonds (9+), and deck[24] would hold the lack of clubs(ja). You would then proceed to deck[1], find a random index of a card to swap with, and swap those cards, etc. (b) Repeat step a) at least 1000 times. Print the deck after the shuffle is done. 3) Deal the cards (after shuffling the deck) by giving one card to the user/player, followed by one card to the computer/dealer, followed by one card to the user/player, etc. until each player get 7 cards. There are only 2 players (computer/dealer and one user/player). The player's hand is represented as a dynamic list of cards. The list is populated with the cards drawn by the player The dealer's hand is represented as a dynamic list of cards. The list is populated with the cards drawn by the dealer Note: the card(s) added to each of the player/dealer's hand (drawn from the deck) must be added to that player/dealer's linked list correctly and MUST be removed from the deck. Write a C program to 1) Create a full deck of 52 cards that are in order. In other words, for each of the four suits, the cards should be in order from Ace (1) through King (13). each card is consisted of a suit [clubs (+),spades (+),hearts (), or diamonds ()) a face (1(Ace) 10, Jacks (I), Queens (Q), and Kings (K)) To simulate the deck of 52 cards, and each of the hands, your team MUST use a dynamic list of cards with the following struct type typedef struct card_s char suit int face struct card s *next; car Print the deck that you create. 2) Shuffle the deck (52 cards). Note: Your code must have a ShuffleCard) function and should work with any size deck of cards, i.e. shuffling 53 cards, 20 cards or 5 cards. One algorithm that you may use to shuffle the deck. (a) For each card in the deck, get a random number in the range of 0 to 51 to be used as the index of the element to swap that card with, ie if deck[0] holds the Jack of clubs +) and the random number generated was 24, and deck[24] holds the 9 of diamonds(9+), then after the first swap, deck[0] would hold the 9 of diamonds (9+), and deck[24] would hold the lack of clubs(ja). You would then proceed to deck[1], find a random index of a card to swap with, and swap those cards, etc. (b) Repeat step a) at least 1000 times. Print the deck after the shuffle is done. 3) Deal the cards (after shuffling the deck) by giving one card to the user/player, followed by one card to the computer/dealer, followed by one card to the user/player, etc. until each player get 7 cards. There are only 2 players (computer/dealer and one user/player). The player's hand is represented as a dynamic list of cards. The list is populated with the cards drawn by the player The dealer's hand is represented as a dynamic list of cards. The list is populated with the cards drawn by the dealer Note: the card(s) added to each of the player/dealer's hand (drawn from the deck) must be added to that player/dealer's linked list correctly and MUST be removed from the deck

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions