Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To a card game of War in java. War is a card game for two players. A standard deck of 52 cards is dealt so

To a card game of War in java.

War is a card game for two players.

A standard deck of 52 cards is dealt so that both players have 26 cards.

During each round of play (or "battle"), both players play a card from the top of their hand face up.

The player who plays the card of the higher rank wins both cards and places them at the bottom of his stack of cards.

If both cards played are of the same rank, then both players play three additional cards face down and then one more card face up (this is called a "war").

The player who wins the war by playing the higher card wins all ten cards.

If the ranks are still the same, additional wars are played until one player wins the turn.

If either player runs out of cards to play, he loses the game.

You will use only ArrayLists to store the cards in this program. This means cards cannot be stored in arrays.

Sample output might look like this:

player 1 plays Card is 9 of Clubs player 2 plays Card is Ace of Diamonds player 2 wins the round player 1 plays Card is 10 of Diamonds player 2 plays Card is Ace of Hearts player 2 wins the round player 1 plays Card is 7 of Clubs player 2 plays Card is 6 of Hearts player 1 wins the round player 1 plays Card is 9 of Hearts player 2 plays Card is 9 of Clubs war war card for player1 Card is xx war card for player2 Card is xx war card for player1 Card is xx war card for player2 Card is xx war card for player1 Card is xx war card for player2 Card is xx war card for player1 Card is 7 of Clubs war card for player2 Card is 10 of Diamonds player 2 wins the war round player 1 plays Card is 6 of Hearts player 2 plays Card is Ace of Hearts player 2 wins the round game over player 2 wins the game

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

Students also viewed these Databases questions

Question

4. Evaluation is ongoing and used to improve the system.

Answered: 1 week ago

Question

6. Effectively perform the managers role in career management.

Answered: 1 week ago