Write a program that deals a number of cards (their numerical values) to a player's hand. To begin, the program asks the player for the values of the deck of cards. Then, the program deals the first two cards of the deck to a player's hand, and asks him if he wants another card. If he does not want a card, the program ends. If he wants a card, the program deals the next available card in the deck, adds it to the player's hand, and asks the player if he wants another card. The dealing process repeats as long as the user continues to accept cards, or until the cards in the deck run out. Card dealing involves copying the available card from the deck vector to another vector, which stores the player's hand, at the next available position. Assume that the deck of cards consists of only 10 cards with numerical values from 1 to 10, which the player will enter by keyboard before the program deals. The following functions must be implemented/used: enterDeckValues. - This function will receive two parameters: a vector that will store the numerical values of the deck of cards, and the number of cards in the deck. The function will fill the deck vector with the numerical values to be entered by keyboard. dealCards. - This function will receive three parameters: a vector that will store the numerical values of the deck of cards; the total number of cards in the deck; and, the vector that will store the numerical values of the player's final hand. The function will assign the first two cards of the deck to the player's hand and then deal cards to the player, assigning numerical values of the available cards in the deck, as explained in the approach. printVector - This function will receive two parameters: a vector and its dimension. The function will print the vector, and will serve to print the values (the vector) of the initial hand and the final hand. I attach screenshots of how it should be executed Translator
Write a program that deals a number of cards (their numerical values) to a player's hand. To begin, the program asks the player for the values of the deck of cards.
Then, the program deals the first two cards of the deck to a player's hand, and asks him if he wants another card. If he does not want a card, the program ends. If he wants a card, the program deals the next available card in the deck, adds it to the player's hand, and asks the player if he wants another card. The dealing process repeats as long as the user continues to accept cards, or until the cards in the deck run out.
Card dealing involves copying the available card from the deck
Assume that the deck of cards consists of only 10 cards with numerical values from 1 to 10, which the player will enter by keyboard before the program deals.
The following functions must be implemented/used:
enterDeckValues. - This function will receive two parameters: a vector that will store the numerical values of the deck of cards, and the number of cards in the deck. The function will fill the deck vector with the numerical values to be entered by keyboard.
dealCards. - This function will receive three parameters: a vector that will store the numerical values of the deck of cards; the total number of cards in the deck; and, the vector that will store the numerical values of the player's final hand. The function will assign the first two cards of the deck to the player's hand and then deal cards to the player, assigning numerical values of the available cards in the deck, as explained in the approach.
printVector - This function will receive two parameters: a vector and its dimension. The function will print the vector, and will serve to print the values (the vector) of the initial hand and the final hand.
I attach screenshots of how it should be executed
Step by step
Solved in 4 steps with 3 images