(Card Shuffling and Dealing)10.10 and 10.11 as picture 1 please write c++program 2 make sure to meet the requirement in
Posted: Sat May 14, 2022 4:09 pm
(Card Shuffling and Dealing)10.10 and 10.11 as picture
1 please write c++program
2 make sure to meet the requirement in below header
file
3 combine the two questions together
//------------for 10.10-------------//
#ifndef CARD_H
#define CARD_H
#include <string>
using namespace std;
class Card
{
public:
static const
int totalFaces = 13; // total number of faces
static const
int totalSuits = 4; // total number of suits
Card( int cardFace,
int cardSuit ); // initialize face and suit
string toString() const; //
returns a string representation of a Card
// get the card's face
int getFace()
const
{
return face;
} // end function getFace
// get the card's suit
int getSuit()
const
{
return suit;
} // end function getSuit
private:
int face;
int suit;
static const
string faceNames[ totalFaces ];
static const
string suitNames[ totalSuits ];
}; // end class Card
#endif
//-------------------------//
#ifndef DECK_OF_CARDS_H
#define DECK_OF_CARDS_H
#include <vector>
#include "Card.h"
using namespace std;
// DeckOfCards class definition
class DeckOfCards
{
public:
DeckOfCards(); // constructor initializes deck
void shuffle(); // shuffles cards
in deck
Card dealCard(); // deals cards in deck
bool moreCards()
const; // are there any more cards left
private:
vector< Card > deck; // represents deck of
cards
unsigned currentCard; // index of
next card to be dealt
}; // end class DeckOfCards
#endif
//-------------------------//
//-----------for
10.11--------------//
#ifndef HAND_H
#define HAND_H
#include <string>
#include <vector>
#include "Card.h"
#include "DeckOfCards.h"
using namespace std;
class Hand
{
public:
// constructor takes 5 cards from Deck
Hand( DeckOfCards &deck );
void print()
const; // display hand
// determine if we have the given scoring hand
bool pair()
const;
bool twoPair()
const;
bool threeOfAKind()
const;
bool fourOfAKind()
const;
bool flush()
const;
bool straight()
const;
private:
vector< Card > hand; // our hand
vector< int > faceCount; //
number of each face
}; // end class Hand
#endif
a » 10.10 (Card Shuffling and Dealing) Create a program to shuffle and deal a deck of cards. The pro- gram should consist of class Card, class DeckOfCards and a driver program. Class Card should provide: a) Data members face and suit of type int. b) A constructor that receives two ints representing the face and suit and uses them to ini- tialize the data members. c) Two static arrays of strings representing the faces and suits. d) A toString function that returns the Card as a string in the form “face of suit." You can use the + operator to concatenate strings. Class DeckOfCards should contain: a) A vector of Cards named deck to store the Cards. b) An integer currentCard representing the next card to deal. c) A default constructor that initializes the Cards in the deck. The constructor should use vector function push_back to add each Card to the end of the vector after the Card is created and initialized. This should be done for each of the 52 Cards in the deck. d) A shuffle function that shuffles the Cards in the deck. The shuffle algorithm should iterate through the vector of Cards. For each Card, randomly select another Card in the deck and swap the two Cards. e) A dealCard function that returns the next Card object from the deck. f) A moreCards function that returns a bool value indicating whether there are more Cards to deal. program should create a DeckOfCards object, shuffle the cards, then deal the 52 cards. 10.11 (Card Shuffling and Dealing Modify the program you developed in Exercise 10.10 so that it deals a five-card poker hand. Then write functions to accomplish each of the following: a) Determine whether the hand contains a pair. b) Determine whether the hand contains two pairs. Determine whether the hand contains three of a kind (e.g., three jacks). d) Determine whether the hand contains four of a kind (e.g., four aces). The driver Determine whether the hand contains a flush (i.e. , all five cards of the same suit). 9) Determine whether the hand contains a straight (i.e., five cards of consecutive face values).
1 please write c++program
2 make sure to meet the requirement in below header
file
3 combine the two questions together
//------------for 10.10-------------//
#ifndef CARD_H
#define CARD_H
#include <string>
using namespace std;
class Card
{
public:
static const
int totalFaces = 13; // total number of faces
static const
int totalSuits = 4; // total number of suits
Card( int cardFace,
int cardSuit ); // initialize face and suit
string toString() const; //
returns a string representation of a Card
// get the card's face
int getFace()
const
{
return face;
} // end function getFace
// get the card's suit
int getSuit()
const
{
return suit;
} // end function getSuit
private:
int face;
int suit;
static const
string faceNames[ totalFaces ];
static const
string suitNames[ totalSuits ];
}; // end class Card
#endif
//-------------------------//
#ifndef DECK_OF_CARDS_H
#define DECK_OF_CARDS_H
#include <vector>
#include "Card.h"
using namespace std;
// DeckOfCards class definition
class DeckOfCards
{
public:
DeckOfCards(); // constructor initializes deck
void shuffle(); // shuffles cards
in deck
Card dealCard(); // deals cards in deck
bool moreCards()
const; // are there any more cards left
private:
vector< Card > deck; // represents deck of
cards
unsigned currentCard; // index of
next card to be dealt
}; // end class DeckOfCards
#endif
//-------------------------//
//-----------for
10.11--------------//
#ifndef HAND_H
#define HAND_H
#include <string>
#include <vector>
#include "Card.h"
#include "DeckOfCards.h"
using namespace std;
class Hand
{
public:
// constructor takes 5 cards from Deck
Hand( DeckOfCards &deck );
void print()
const; // display hand
// determine if we have the given scoring hand
bool pair()
const;
bool twoPair()
const;
bool threeOfAKind()
const;
bool fourOfAKind()
const;
bool flush()
const;
bool straight()
const;
private:
vector< Card > hand; // our hand
vector< int > faceCount; //
number of each face
}; // end class Hand
#endif
a » 10.10 (Card Shuffling and Dealing) Create a program to shuffle and deal a deck of cards. The pro- gram should consist of class Card, class DeckOfCards and a driver program. Class Card should provide: a) Data members face and suit of type int. b) A constructor that receives two ints representing the face and suit and uses them to ini- tialize the data members. c) Two static arrays of strings representing the faces and suits. d) A toString function that returns the Card as a string in the form “face of suit." You can use the + operator to concatenate strings. Class DeckOfCards should contain: a) A vector of Cards named deck to store the Cards. b) An integer currentCard representing the next card to deal. c) A default constructor that initializes the Cards in the deck. The constructor should use vector function push_back to add each Card to the end of the vector after the Card is created and initialized. This should be done for each of the 52 Cards in the deck. d) A shuffle function that shuffles the Cards in the deck. The shuffle algorithm should iterate through the vector of Cards. For each Card, randomly select another Card in the deck and swap the two Cards. e) A dealCard function that returns the next Card object from the deck. f) A moreCards function that returns a bool value indicating whether there are more Cards to deal. program should create a DeckOfCards object, shuffle the cards, then deal the 52 cards. 10.11 (Card Shuffling and Dealing Modify the program you developed in Exercise 10.10 so that it deals a five-card poker hand. Then write functions to accomplish each of the following: a) Determine whether the hand contains a pair. b) Determine whether the hand contains two pairs. Determine whether the hand contains three of a kind (e.g., three jacks). d) Determine whether the hand contains four of a kind (e.g., four aces). The driver Determine whether the hand contains a flush (i.e. , all five cards of the same suit). 9) Determine whether the hand contains a straight (i.e., five cards of consecutive face values).