Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C Programming using C code, This is War War is a card game using a standard 52 card deck. The rules are pretty simple*:

In C Programming using C code,

This is War

War is a card game using a standard 52 card deck. The rules are pretty simple*:

THE GOAL

To be the first player to win all 52 cards

DEALING

The deck is divided evenly, with each player receiving 26 cards, dealt one at a time, face down. Anyone may deal first. Each player places his stack of cards face down, in front of him/her.

THE PLAY

Each player turns up a card at the same time and the player with the higher card takes both cards and puts them, face down, on the bottom of his stack.

If the cards are the same rank, it is War. Each player turns up one card face down and one card face up. The player with the higher cards takes both piles (six cards). If the turned-up cards are again the same rank, each player places another card face down and turns another card face up. The player with the higher card takes all 10 cards, and so on.

HOW TO KEEP SCORE

The game ends when one player has won all the cards.

*Instructions Taken from http://www.bicyclecards.com/how-to-play/war/

--------------------------------------

The assignment is as follows: implement this card game. I expect the console to display every rounds outcome. An example is shown below:

[Player 1]: Ace

[Player 2]:

4 Player 1 wins the round!

----------

[Player 1]: Queen

[Player 2]: King

Player 2 wins (2) cards for this round!

----------

[Player 1]: 2

[Player 2]: 2

This is War!

[Player 1]: 7

[Player 2]: 8

Player 2 wins (6) cards for this round!

I expect at the end there to be an indication of who won the game and some statistics of the game. An example is shown below:

Player 1 wins the game!

Rounds Played: 36

Wars Declared: 4

Note that each time you run this game it will be different. It might be in your best interest to test on smaller problems. For example, manually create a deck of 1 card for player 1 and a deck of 1 card for player 2 and test the if statement to see who wins. Then create another deck for testing the war scenario. Etc.

You may assume:

Jacks = 11, Queens = 12, Kings = 13, Ace = 14.

You must however display the word Jack, Queen, King, or Ace on the screen when showing who won a round.

if a player gets in war and cant play the two required cards (one face down and one face up), that player loses the game.

If using a queue, when someone wins a round, add those cards to the bottom of the deck.

If using a stack, when someone wins a round, add those cards to a separate pile. Once your deck runs out, use that separate pile as your deck.

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

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions

Question

2. Discuss the steps in preparing a manager to go overseas.

Answered: 1 week ago

Question

8. Measure the effectiveness of the succession planning process.

Answered: 1 week ago