Use inheritance and classes to represent a deck of playing cards. Create a Cardclass that stores the suit (e.g. Clubs, Diamonds, Hearts, Spades), and name (e.g. Ace, 2, 10, Jack) along with appropriate accessors, constructors, and mutators. Next, create a Deck class that stores a vector of Card objects. The default constructor should create objects that represent the standard 52 cards and store them in the vector. The Deck class should have functions to: • Print every card in the deck • Shuffle the cards in the deck. You can implement this by randomly swapping every card in the deck. • Add a new card to the deck. This function should take a Card object as a parameter and add it to the vector. • Remove a card from the deck. This removes the first card stored in the vector and returns it. • Sort the cards in the deck ordered by name

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.2: Providing Class Conversion Capabilities
Problem 6E
icon
Related questions
Question
 

please use C++ Programming Language to answer the following question

Use inheritance and classes to represent a deck of playing cards. Create a Cardclass that stores the suit (e.g. Clubs, Diamonds, Hearts, Spades), and name (e.g. Ace, 2, 10, Jack) along with appropriate accessors, constructors, and mutators.

Next, create a Deck class that stores a vector of Card objects. The default constructor should create objects that represent the standard 52 cards and store them in the vector. The Deck class should have functions to:

• Print every card in the deck

• Shuffle the cards in the deck. You can implement this by randomly swapping every card in the deck.

• Add a new card to the deck. This function should take a Card object as a parameter and add it to the vector.

• Remove a card from the deck. This removes the first card stored in the vector and returns it.

• Sort the cards in the deck ordered by name.

Next, create a Hand class that represents cards in a hand. Hand should be derived from Deck. This is because a hand is like a more specialized version of a deck; we can print, shuffle, add, remove, or sort cards in a hand just like cards in a deck. The default constructor should set the hand to an empty set of cards.

Finally, write a main function that creates a deck of cards, shuffles the deck, and creates two hands of 5 cards each. The cards should be removed from the deck and added to the hand. Test the sort and print functions for the hands and the deck. Finally, return the cards in the hand to the deck and test to ensure that the cards have been properly returned.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,