Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Something Like War (Write in Java) You are going to create a card game that plays kinda like the game of war. You should begin
Something Like War (Write in Java) You are going to create a card game that plays kinda like the game of war. You should begin by creating two arrays of size 26. One array to store player l's cards and a second to store player 2's cards. Initialize each spot in each array to a random number 2-14, where 2 is a card with the value of 2, 3 a card with the value of 3, ... 11 a card with the value of Jack, 12 Queen, 13 King, and 14 Ace. Self-check: Print out a list of the cards for each player using a for-loop so that it prints something like: Player 1 has [11, 12, 14, 14, 3, 2, 4, 8, 910, ... ] Player 2 has [12, 14, 13, 14, 2, 7,5, 3, 8, 12,...] We are printing the cards only so that we can check that the rest of the game plays correctly and that the spots were initialized correctly. At the end of the game, we will remove this, so that the user doesn't know what the card are as the beginning. Cycle through the indices 0 25 and compare which player has a higher card value for each "hand (index). You should keep a tally of how many 'hands' each player wins. For example, if we use the arrays above, in the first hand at the first index - index 0), player 2 would win the hand because he has a 12 when player 1 has a 11. For the hands shown, player 1 would score 4 hands, player 2 would score 5, and there would be 1 tie. Print out how many wins each player has and how many ties were made. Additionally: Show each hand one by one and include how many points have been earned by each player up to that time. For example, for each hand: Player 1 Player 2 Player 2 wins!! 11 12 Player 1: 0 Player 2: 1 Ties: 0 Display J, Q, K, and A instead of 11, 12, 13, 14 respectively when printing out hands and the initial array to the screen
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