### class BlackJack ### The role of the Blackjack class is to encapsulate all of
ID: 3541680 • Letter: #
Question
### class BlackJack ###
The role of the Blackjack class is to encapsulate all of logic associated with playing the game of blackjack. Note that all output visible in the Sample Output section is generated by BlackJack's play() method. The play() method should operate as follows:
### Program Start ###
1. Output an introduction
### Starting with the player, do the following ###
1. Deal the player a card.
2. Add the card's value to the player's total hand
3. Output the value of the card just dealt and the player's current hand total (score)
4. Ask the player if he would like to hit or stand
5. If the player hits, go back to #1
### After the player busts (goes over 21) or stands ###
1. If the player has not busted, begin computer's play
2. Deal the computer a card
3. Add the value of the card to the computer's hand total (score)
4. If a card causes the computer to bust (go over 21), output a message. Go to step #7.
5. If the computer's hand total is less than 17, it must take another card (hit). Go to step #2.
6. If the computer's hand is 17 or more, the computer stands.
7. Stop computer play
### When both player and computer are done ###
1. If the player has not busted (gone over 21) and the computer busted, the player wins
2. If the player has not busted, the computer has not busted, and the player's hand total is greater than the computer, then the player wins
3. If the player has not busted, the computer has not busted, and the player's hand total is less than the computer's then the computer wins
4. If the player has busted, then the computer wins.
### class Card ###
We use the card class to represent an individual card in a deck. Cards have a suit (Club, Diamond, Heart, Spade) and a rank (e.g. Two, Ten, Jack, Ace). Suit_t and Rank_t are enumerations that list the possible values. To simplify, we will assume that aces only play one role in blackjack and have a value of 11. Note that the Card class has a getRankValue() method that will return the integer value of the card (i.e. 2-11 depending on the card's base value).
### class Deck ###
The Deck class is merely a collection of 52 cards. The private member variable "_used_indices" is used to track the cards previously dealt. Calling the resetDeck() method should re-initialize the deck of cards and clear out the list of previously dealt cards. For convenience, the Deck's constructor should automatically call resetDeck() to initialize the deck.
Here is what I have got so far and please used the same functions' names:
### Header.h ###
#include <iostream>
#include <ctime>
#include<iomanip>
using namespace std;
char IsGameOver;
class Card
{
public:
enum rank {ACE = 1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING};
enum suit {CLUBS, DIAMONDS, HEARTS, SPADES};
class card {
private: Suit_t_suit;
Rank_t_rank;
public: Card();
Card(Suit_t suit, Rank_t rank);
Suit_t getSuit() const;
string getSuitName() const;
Rank_t getRank() const;
int getRankValue() const;
string getRankName() const;
};
class Deck {
private: int _used_indices[52];
card -cards[52];
public: Deck();
void resetDeck();
Card getNextCard();
};
class BlackJack {
private: int -player_score;
int -computer_score;
public: BlackJack();
void play();
}
#### Source.ccp ###
#include <iostream>
#include <ctime>
#include<iomanip>
using namespace std;
//constructor 1
Card::Card()
{
_suit=club;
_rank=two;
}
//constructor 2
Card::Card(suit_t suit), Rank_t rank)
{
_suit=suit;
_rank=rank;
}
Suit_t Card::getSuit() const
{
return _suit;
}
string Card::getSuitName ()const
{
string suit_names[]={"club", "Diamond", "Heart", "Spade"};
return suit_names[getSuit()];
}
Rank_t Card::getRank() const
{
return _rank;
}
Note: Please I need them according to the above rules which means please don't copy codes for the internet.
Explanation / Answer
??
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.