Question: Using C++: This assignment will use a Card class to build a Deck class. Then you will use the Deck class to play a card

Using C++:

This assignment will use a Card class to build a Deck class. Then you will use the Deck class to play a card game called WAR.

WAR is a simple game 2 people play. One card is dealt to each player, face up. The highest value card wins. If the cards are the same, then its a tie. Announce the winner - Game over. Then you ask if the player want to play again.

You will have 2 classes:

The Deck class which will create the deck of cards

The Card class which creates cards

The main logic of the program will be in the main class. You will use the Card class and the Deck class to play the game.

Here the methods you will need to build. Feel free to add more if you need them.

public class Deck

public Deck( ) // constructor which creates a deck of 52 cards

public void refreshDeck(); // reset the deck so it looks like a new deck.

public Card deal( ) // deal a card

public void shuffle( ) // shuffle the cards in the deck. Do not allow the user to shuffle a partial deck.

publid int cardsLeft( ) // return the number of cards left in the deck

public void showDeck( ); // show all the cards in the deck

public class Card

public Card( ) // create a blank card

public Card ( char s, char r ) // constructor to create a card, setting the suit and rank

public void setCard( char s, char r) // set an existing blank card to a particular value

public int getValue( ) // return the point value of the card. Ace = 1, 2 thru 10, Jack = 11, Queen = 12, King = 13

public void showCard( ) // display the card

Here is a sample of how the game will play out:

Get ready to play WAR!!!

There are 52 cards in the deck.

...dealing....

One for you...

Two of Diamonds

-------

[2 ]

[ ]

[ * * ]

[ * * ]

[ * * ]

[ ]

[ 2]

-------

One for me...

Ace of Hearts

-------

[A ]

[ ** ** ]

[* * *]

[ * * ]

[ * * ]

[ * ]

[ A]

-------

You Win!!!!

Wanna play again? (yes)

There are 50 cards in the deck.

...dealing....

One for you...

Queen of Spades

-------

[Q ]

[ * ]

[ * * ]

[ ***** ]

[* * *]

[ * ]

[ Q]

-------

One for me...

Ten of Clubs

-------

[10 ]

[ * ]

[* * *]

[ * * * ]

[ * ]

[ * ]

[ * 10]

-------

You Win!!!!

Wanna play again? (no)

Goodbye

You will need to provide a menu with the following choices:

Get a new card deck

Show all remaining cards in the deck

Shuffle

Play WAR!

Exit

Things to consider:

You cannot continue the game if there are not enough cards in the deck.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!