Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M92477703
  • Price:- $80

Priced at Now at $80, Verified Solution

Have any Question?


Related Questions in C/C++

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As