Creates of the given face value computes and stores the


Project Assignment: Blackjack Card Class

New Chapters Covered:

• Structures and Classes
• Constructors and Other Tools
• Operator Overloading and Friends

Specification:

You will design a Card class which will be used for blackjack-style playing cards. Because the expected game is Blackjack, we will want to design functionalities and store information which is relevant to that game in particular. For this assignment, you are not required to create a full blackjack game. Rather, you are only required to create the class for handling the card objects.

A Deck of Cards:

Each card has one of four suits: Spades, Clubs, Diamonds, and Hearts.

There are 13 face values: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King

The 52 cards in the deck represent all possible pairs of a suit and face value.

A Hand of Cards - Evaluating Points:

A hand is a subset of the cards in the deck. In blackjack a hand is worth a certain number of points. The goal is to have a hand which is worth as close to 21 points as possible without going over.

The points of a particular card are based upon the card's face value and, in the case of the Ace, based upon the total value of the hand.
Face values 2 through 10 are worth points equal to their face value.

Face values of Jack, Queen, and King are each worth 10 points.

An Ace is worth 11 points if the hand is worth less than or equal to 21 points; otherwise the Ace is worth 1 point.

Card Class Public Members:

• 4 constructor functions:

Card();

creates card with default private data for an Ace of Spades.

Card(intmyvalue);
creates of the given face value. Computes and stores the appropriate points for the given face value. Set the suit as Spades.

Card(intmysuit, intmyvalue);
creates card of the given suit and face value. Computes and stores the appropriate points for the given face value.

Card(intmysuit, intmyvalue, intmypoints);
Creates card of the given suit and face value worth the given number of points. (Will use to create composite cards as part of the + overloading)

• 2accessor functions:

intGetPoints() const;
Returns the integer value of the calling card's point value.

stringGetCardName()const;

Returns a string describing the card's suit and face value (see the sample output for examples). Returned string should be of the form: "Face Value Name" of "Suit Name"

• 3 comparison operator overloads:

friend bool operator == (const Card& lhs, const Card&rhs);

Returns true if the two cards have the same value and false otherwise. Output an error message and exit if comparison is made to a composite card.

friend bool operator < (const Card& lhs, const Card&rhs);

Returns true if the left card's value is less than the right card's and false otherwise. Properly treats Aces as being greater than the other cards. Output an error message and exit if comparison is made to a composite card.

friend bool operator > (const Card& lhs, const Card&rhs);

Returns true if the left card's value is greater than the right card's and false otherwise. Properly treats Aces as being greater than non-aces cards. Output an error message and exit if comparison is made to a composite card.

• 1 addition operator overload:

friendconst Card operator +(const Card& lhs, const Card&rhs);

Add the point values of two cards together and compute their combined points as part of a blackjack hand. Properly reduces the value of an ace to 1 if the combined value would be greater than 21. Returns a composite card with the composite point value. Assigns a composite suit of 5 to the returned card. Assigns the composite card a face value of Ace if one of the two cards was an Ace and its value was not reduced to 1; otherwise assigns a composite face value of 14.Pseudocode for the algorithm is as follows:

New_Points = card1_points + card2_points

If either card1 or card2 is an ace:

If New_points> 21:
New_points = New_points - 10
New_FaceValue = Composite Face Value
Else:
New_FaceValue = Ace
Else:
New_FaceValue = Composite Face Value
Return NewCard with New_Points, New_FaceValue, and Composite Suit.

Attachment:- C++-Project.rar

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Creates of the given face value computes and stores the
Reference No:- TGS02464532

Now Priced at $80 (50% Discount)

Recommended (90%)

Rated (4.3/5)