Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in C ++ A deck of cards has 52 cards. Each card has a suit and a rank. The suit of a card can be
in C ++
A deck of cards has 52 cards. Each card has a suit and a rank. The suit of a card can be either SPADES, HEARTS, CLUBS, or DIAMONDS. The rank of a card can be either 2,3,4,5,6,7,8,9,10, Jack, Queen, King. or Ace. A perfect shuffle is performed by cutting the deck in balf and then interieaving cards from each half deck. Example: suppose the cards were numbered from 1 to 52. After a perfect shuifle, card 1 will be followed by card 27, then card 2, then card 28, etc. If you keep performing perfect shuffles on a deck of cards, eventually you will return to a point where the order of the cards matches the original order of the deck of cards. Requirements: High-level requirement: Write a program to model cards/decks and determine how many perfect shutfles it takes to return the deck to its original configuration. As you write your program use the best practices and C++ constructs we discussed in class: enums, classes, public/private data members, etc. Printing a Card: Spades 5 Hearts H Dlartvonds tia D Clubs me C For card ranks, use the numeric values 2 - 10 and J for Jack, Q for Queen, K for King A for Ace Examples: 25, 100, jS, KH,AC Printing a Deck: Print each card in the deck followed by a comma and space. There should not be a comma after the last card. Enclose the deck in bracket. Example: [2H,3H,4H,AH,2D,3D,4D,,AD,,KS,AS] Initial Deck Configuration: When you create a new deck, the order of the cards should follow these rules: 1. All spades followed by all hearts, all clubs, all diamonds 2. Within each suit, the first card has a rank of 2 . The last card has a rank of Ace [2S,3S,4S,5S,6S,7S,,JS,QS,KS, AS 2Hm.m 2C 2D,... AD] Other Requirements: At a minimum, you should have functions/methods to: 1. Initialize a deck of cards 2. Perform a perfect shutfle 3. Print a deck of cards 4. Compare two decks of cards to see if they are in the same configuration 5. Make sure to use h and .epp files separately for each class you create. Make sure to have header guards. Driver Program (main. cpp) : 1. Create a deck of cards. 2. Print the initial deck. Driver Program (main.cRp): 1. Create a deck of cards. 2. Print the initial deck. 3. Perform a perfect shuffle. 4. Print the deckagain. 5. Keep perfect shuffling until the deck returns to its original configuration. 6. Print out the number of perfect shutfles it took. Sample Output (Make sure it matches exactly with spaces as well): orieinas decki ota Ater ist Nerfect shuthe: 4. Wo, ini, ales, shutrie counti s 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