Write a C++ program that plays the card game of Hearts. The C++ program should include your overloaded < operator, sort function, and shuffle function.
The program must have these features:
• Four hands only
• At least three classes – Card, Deck, and Player.
• Use the try-throw-catch statements when a player tries to play an incorrect card, such as not following suit on a trick (see rules of the game).
Please keep the main program simple. Most of our logic should be in member functions for classes.
The display should look something like this:
HAND 1 HAND 2 HAND 3 HAND 4
---------- ---------- ----------- -----------
3 points 11 points 2 points 0 points
----------- ----------- ----------- -----------
Spade Ace Spade 5 Heart 7 Spade 10
Spade 2 Heart Jack Diamond Ace Spade 4
Heart Queen Club 10 Diamond King Heart 2
Heart 4 Club 3 Diamond Queen Diamond Jack
Diamond Jack Club 2 Club 9 Diamond 8
. . . .
. . . .
. . . .
Club 4 Club Queen enter card:
Object of the Game
The player with the lowest score wins.
At the end of each game, players count the number of hearts they have taken as well as the queen of spades.
A total of 26 points are awarded:
• Each heart counts as 1 point
• Queen of spades counts as 13 points
When one player takes all 13 hearts and the queen of spades, instead of losing 26 points, that player scores zero and each opponent scores 26 points. This is called ‘shooting the moon’.
There are four players, each with 13 cards initially. Players sit around a table. To deal, start with any player and deal cards one at time clockwise.
Play proceeds in rounds, in which each player plays one card, in clockwise order around the table. Playing the first card of a round is called ‘leading’. The player holding the 2 of clubs leads the first round. Subsequently, the winner of one round leads the next round.
Following the first card of a round, the remaining players must play a card in the same suit. A player with no cards in this suit may play a card in any other suit. The highest card of the suit that was led wins the round. The winner of a round and accumulates points for the queen of spades or any hearts.
Rounds are sometimes called ‘tricks’.
Enable games with three or five players.
Implement these three special rules of play:
• After cards are dealt but before the first trick, each player selects three cards and passes them to the player on the right (clockwise).
• If a player has no clubs when the first trick is led, a heart or the queen of spades cannot be discarded.
• Hearts may not be led until a heart or the queen of spades has been discarded. (The queen of spades can be led at any time.)