am trying to compile a poker program in c++ and it still doesn't work: main.cpp: #include #include #include #include #include #include "card.h" #include "deck.h" #include "hand.h" using namespace std; /************************************************************ * FunctionName * * Function description *
I am trying to compile a poker program in c++ and it still doesn't work:
main.cpp:
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <sstream>
#include "card.h"
#include "deck.h"
#include "hand.h"
using namespace std;
/************************************************************
* FunctionName *
* Function description *
* *
* *
************************************************************/
int main()
{
string repeat = "Y";
Deck myDeck;
Hand myHand;
string exchangeCards;
while (repeat == "Y" || repeat == "y")
{
cout << endl;
myHand.newHand(myDeck);
myHand.print();
cout << endl;
cout << "Would you like to exchange any cards? [Y / N]: ";
getline(cin, exchangeCards);
while (exchangeCards != "Y" && exchangeCards != "y" && exchangeCards != "X" && exchangeCards != "n")
{
cout << "Please enter Y or N only: ";
getline(cin, exchangeCards);
}
if(exchangeCards == "Y" || exchangeCards == "y")
{
myHand.exchangeCards(myDeck);
}
cout << endl;
myHand.print();
cout << endl;
myDeck.reset(); // Resets the deck for a new game
cout << "Play again? [Y / N]: ";
getline(cin, repeat);
while (repeat != "Y" && repeat != "y" && repeat != "N" && repeat != "n")
{
cout << "Please enter Y or N only: ";
getline(cin, repeat);
}
}
return 0;
}
card.h:
#ifndef CARD_H
#define CARD_H
#include <iostream>
#include <string>
using namespace std;
// Sources: https://en.wikipedia.org/wiki/Standard_52-card_deck
// https://en.wikipedia.org/wiki/Pip_(counting)
const string pips[] = {"Ace", "Two", "Three", "Four", "Five",
"Six", "Seven", "Eight", "Nine", "Ten",
"Jack", "Queen", "King"};
const string suits[] = {"Hearts", "Spades", "Clubs", "Diamonds"};
class Card
{
public:
// Get card value
int get();
// Set card value
void set(int value);
string getPip();
string getSuit();
// Print card value
void print();
private:
int m_cardValue;
};
#endif
Deck.h:
#ifndef DECK_H
#define DECK_H
#include <vector>
#include <cstdlib> // srand(), rand()
#include <ctime> // time()
#include "card.h" // Include card header file here
using namespace std;
class Deck
{
public:
// class Constructor
Deck();
// Reset deck to new state (completely undealt)
void resetDeck();
// Print all cards in the undealt deck
void printUndealtDeck();
// Print all cards in the dealt deck
void printDealtDeck();
// Get size of the undealt deck
const int getSizeUndealtDeck();
// Get size of the dealt deck
const int getSizeDealtDeck();
// Deal a single card
Card dealCard(); // Is the dealCard() here an accessor or mutator function???
private:
vector<Card> m_undealtDeck; // Undealt cards
vector<Card> m_dealtDeck; // Dealt cards
};
#endif
hand.h
#ifndef DECK_H
#define DECK_H
#include <vector>
#include <cstdlib> // srand(), rand()
#include <ctime> // time()
#include "card.h" // Include card header file here
using namespace std;
class Deck
{
public:
// class Constructor
Deck();
// Reset deck to new state (completely undealt)
void resetDeck();
// Print all cards in the undealt deck
void printUndealtDeck();
// Print all cards in the dealt deck
void printDealtDeck();
// Get size of the undealt deck
const int getSizeUndealtDeck();
// Get size of the dealt deck
const int getSizeDealtDeck();
// Deal a single card
Card dealCard(); // Is the dealCard() here an accessor or mutator function???
private:
vector<Card> m_undealtDeck; // Undealt cards
vector<Card> m_dealtDeck; // Dealt cards
};
#endif
This is the error I am getting.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps