Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This program involves writing a VERY simplified version of the card game War. You may know this game or not but my rules are these
This program involves writing a VERY simplified version of the card game War. You may know this game or not but my rules are these 1. Split the deck between player1 and player2. Only the face values matter (2-14) and not the suits 2. Each player puts a card down on the table. The higher face value wins that hand. If the card values match, you will simply indicate tie and neither player wins.The original rules would require you to use a queue, linked list, or dynamic array so that the winning player keeps the cards from the hand. l've cut that part out of this game. Just play each players 26 card deck 1 time and tally the results You can use a 2D array or 2 1D arrays to hold the 52 card deck. No need to store suits. You will want to place the face values (4 each of 2-14) into one array and a boolean or other appropriate value in the other array to make sure you don't draw the same card twice. Your players will each have their own array of 26 cards -The cards MUST be randomly given to the players so that their order within each player's deck is never the same. Just generate a random number between O and 51. If the value in the deck has already been given out, generate another random number and try again. How do you know if it has been given out? That's what the second array (2 x 1D arrays) or second row (in a 2D array) is used for -The player with the most hand wins is the game winner. If there is a tie, indicate that the game is a tie -You will output the game to the screen in this way: Player1 Player2 Winner 12 3 7 13 etc.. Game Winner is Player1! Player1 Tie Player2 Player1 14 2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started