Computes and stores appropriate points for given face value

Assignment Help C/C++ Programming
Reference no: EM131669002

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

Reference no: EM131669002

Questions Cloud

Formulate a binary integer linear programming model : Formulate a binary integer linear programming model that will enable Bayside's management to determine the locations for the camera systems.
Recommend the use of wds : In what type of situations would you recommend the use of WDS and in which you would not Provide an example of each type of situation.
What are your companys strengths : What are your company's strengths? What are your company's weaknesses? What are your company's opportunities? What are your company's threats?
Steps needed to perform the system rmdir : Briefly explain the steps needed to perform the system rmdir("d2"), which removes the directory called d2 from the current directory.
Computes and stores appropriate points for given face value : Creates of the given face value. Computes and stores the appropriate points for the given face value. Set the suit as Spades.
How many units of each subassembly roedel should purchase : Determine how many units of each subassembly Roedel should manufacture and how many units of each subassembly Roedel should purchase.
Review article related in bloomberg business : How does the subject matter in this article tie in with at least three topics or concepts that are discussed in the textbook?
What are the revenue recognition policies for each company : MFE 6110 - What are the revenue recognition policies for each company and How do the two companies account for their intangible assets
Address verification in ipv4 and ipv6 : How does ICMPv6 differ from ICMPv4 and what is the difference in how automatically generated addresses are verified in IPv4 and IPv6.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write an abstract data type

Write an abstract data type in C++ or Java (find which language you used) for rational numbers (a numerator and a denominator, both in integers).

  Compute sums for each of the two inventories

The object is to compute sums for each of the two inventories and generate a total inventory count for each one. i need to print out the total number of items found in each inventory, total counts and the average for each inventory.

  Conversion of programming languages

How to convert java proram into C++ program.

  Write a c program that prompts the user to enter some data

Write a C program that prompts the user to enter some data regarding some clients. The user should prompt for client account number (a UNIQUE positive integer between 1 and 1000).

  Why does the neverwet spray protect it from water

As is know, acetone is a polar molecule like water, so isn't it suppose to mix? So my question is: why does the Neverwet spray protect it from water but not from oils and detergents?

  Draws a pyramid consisting of bricks

Write a C program that draws a pyramid consisting of bricks arranged in horizontal rows, so that the number of bricks in each row decreases by one as you move up the pyramid.

  Convert infix to postfix expression

For every postfix expression there exists a corresponding and uniquely defined infix expression that evaluates to the same number.

  Implement a class called hugeinteger

Using your own Linked List implementation (see attached), implement a class called HugeInteger that represents arbitrary sized integers and supports addition only. You may only use the tools that have introduced in class, and you MAY NOT use Java'..

  Which of the given functions has a constant growth rate

Which of the following functions has a constant growth rate? What is the output in the statement cout

  Perform the five arithmetic operations

A program that declares and prompts the user to enter two integer and performs the five arithmetic operations

  Write a c function for reversing circular single linked list

Let A and B be two structures of type linked list. Write a function for creating new linked list C that contains elements alternately from A and B beginning with first element of A. If you run out of the elements in one of the lists then append the r..

  Write a program that uses a string array to store a list

The program should allow the user via a menu to add an item to the list, clear the list, and display the list. You may assume that the list will never need to contain more than 10 items.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd