Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer using editable code... b. In Chapter 7, you created a War2 card game that randomly selects two Card objects (one for the player

Please answer using editable code...image text in transcribed

b. In Chapter 7, you created a War2 card game that randomly selects two Card objects (one for the player and one for the computer) and declares a winner or a tie based on the card values. Now create a game that plays 26 rounds of War, dealing a full deck with no repeated cards. Some hints: Start by creating an array of all 52 playing cards, as in Part a of this exercise. . Select a random number for the deck position of the player's first card, and assign the card at that array position to the player. Move every higher-positioned card in the deck "down" one to fill in the gap. In other words, if the player's first random number is 49, select the card at position 49, move the card that was in position 50 to position 49, and move the card that was in position 51 to position 50. Only 51 cards remain in the deck after the player's first card is dealt, so the available-card array is smaller by one. In the same way, randomly select a card for the computer and "remove" the card from the deck. Display the values of the player's and computer's cards, compare their values, and determine the winner. When all the cards in the deck are exhausted, display a count of the number of times the player wins, the number of times the computer wins, and the number of ties. Save the game as War3.java

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: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions