Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ programming: (Please help me out with this assignment, thank you!) Your solution should for this assignment consist of five (5) files : Card.h (class

C++ programming: (Please help me out with this assignment, thank you!)

Your solution should for this assignment consist of five (5) files:

Card.h (class specification file)

Card.cpp (class implementation file)

DeckOfCards.h (class specification file)

DeckOfCards.cpp (class implementation file)

assingment.cpp (application program)

Class Card should provide:

a. Data members face and suit of type int. These are index numbers for the faces and suits arrays described in step c below.

b. A constructor that receives two ints representing the face and suit and uses them to initialize the data members.

c. Two static arrays of strings representing the faces and suits. The faces array stores the strings Ace, Deuce, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, and King. The suits array stores the strings Hearts, Diamonds, Clubs, and Spades.

d. A toString function that returns the Card as a string in the form face of suit. For example, Ace of Hearts. You can use the + operator to concatenate strings.

Class DeckOfCards should contain:

a. A vector of Cards named deck (of type Card the Card class) to store the Cards. There are 52 cards in a deck, which is the number of faces (13) times the number of suits (4).*

b. An integer currentCard representing the next card to deal. This is used as an index number for the deck vector from step a.

c. A default constructor that initializes the Cards in the deck. You can initialize the faces and suits in the order shown above in step c of the Card class.**

d. A shuffle function that shuffles the Cards in the deck. The shuffle algorithm should iterate through the array of Cards. For each Card, randomly select another Card in the deck and swap the two Cards.

e. A dealCard function that returns the next Card object from the deck vector.

f. A moreCards function that returns a bool value indicating whether there are more Cards to deal. This function will return false if all 52 cards have been dealt, otherwise it returns true.

*Note that this is composition: a deck of cards has cards, so the DeckOfCards class has a vector of type Card as one of its private member variables

This means each index in the deck vector stores an entire Card object, and each Card object in turn consists of a face (type string) and a suit (type string). For example:

deck[0] = Card(Ace, Hearts)

deck[1] = Card(Deuce, Diamond) ....

deck[51] = Card(Queen, Spades)

** The faces array stores the strings Ace, Deuce, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, and King. The suits array stores the strings Hearts, Diamonds, Clubs, and Spades. You can initialize the arrays following this order.

The application program should create a DeckOfCards object, shuffle the cards, then deal the 52 cards.

Each time you run the program you should see all 52 cards, but they should be displayed in a different order each time the program is run (as shown below).

image text in transcribed

Jack of Spades King of Spades Queen of Diamonds Queen of Hearts ThreeofDiamonds Four of Clubs Ten ofDiamonds Six ofClubs Deuce of Clubs Seven ofClubs Queen of Spades Eight of Hearts Jackof Hearts Nine of Diamonds Seven of Hearts Ace ofDiamonds hree of Spades King of Hearts Seven of Spades Three of Hearts Deuce of Spades Five of Spades Four of Hearts Nine Of CLubs Eight of Clubs Nine of Spades Eight of Diamonds Jack of Clubs Threeof Clubs Four of Diamonds Deuce of Hearts Ace of Clubs Five of Hearts Ace of Hearts Ten of CIubs Jack of Diamonds King of Clubs Five ofDiamonds Six of Spades King of Diamonds Eight of Spades Queen of Clubs Five of Clubs Ten of Hearts Six of Hearts Seven ofDiamonds Nine of Hearts Deuce ofDiamonds Ten of Spades Ace of Spades Four of Spades Six ofDiamonds Sample run 2: Six of Hearts Deuce of Spades Ace of Diamonds Eight of Diamonds Eight of Hearts Four of Hearts Queen of Diamonds Five of Clubs Nine of Spades Seven of Diamonds Ten of Hearts King of Hearts Ten of Diamonds Nine Of D1amonds Ace of Hearts Jack of Hearts Eight of Spades Four of Clubs Jack of Spades Four of Spades Eight of Clubs Seven ofClubs Ten of Spades Six of Clubs Press any key to continue . . Three of Club Five of Spades Nine of Clubs Four ofDiamonds Deuce ofClubs Jack of D1amonds Five of Hearts Three of Spades Six of Diamonds Queen of Spades Deuce of Diamonds King of Diamonds Jack of Clubs Seven of Hearts Queen of Hearts Seven of Spades King of Clubs Deuce of Hearts Threeof Hearts Ace of Spades Tenof Clubs King of Spades Ace of Clubs Five of DiamondsQueen of ClubS Six of Spades Nine of Hearts Threeof Diamonds

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_2

Step: 3

blur-text-image_3

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

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions

Question

The company openly shares plans and information with employees.

Answered: 1 week ago