I've been asking about this poker game that I have been trying to compile in c++. Main.cpp #include #include #include #include #include #include "card.h" #include "deck.h" #include "hand.h" using...


I've been asking about this poker game that I have been trying to compile in c++.


Main.cpp


#include
#include
#include
#include
#include
#include "card.h"
#include "deck.h"
#include "hand.h"
using namespace std;
int main()
{
string repeat = "Y";
Deck myDeck;
Hand myHand;
string exchangeCards;
while (repeat == "Y" || repeat == "y")
{
cout <>
myHand.newHand(myDeck);
myHand.print();
cout <>
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 <>
myHand.print();
cout <>
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;
}


Deck.h


#ifndef DECK_H
#define DECK_H
#include
#include // srand(), rand()
#include // time()
#include "card.h" // Include card header file here
using namespace std;
class Deck
{
public:


Deck();
void resetDeck();
void printUndealtDeck();
void printDealtDeck();
const int getSizeUndealtDeck();
const int getSizeDealtDeck();
Card dealCard(); // Is the dealCard() here an accessor or mutator function???
private:
vector m_undealtDeck; // Undealt cards
vector m_dealtDeck; // Dealt cards
};
#endif


hand.h:


#ifndef HAND_H
#define HAND_H
#include
#include "card.h" // Include card header file here
#include "deck.h" // Include deck header file here
using namespace std;
const int NUM_CARDS_ON_HAND = 5;
class Hand
{
public:
void newCard(Deck& deck, int location);
void newHand(Deck& deck);
void exchangeCards(Deck& deck);
void print();
private:
Card m_hand[NUM_CARDS_ON_HAND]; // A hand consists of 5 cards
};
#endif


card.h:


#ifndef CARD_H
#define CARD_H
#include
#include
using namespace std;
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:
int get();
void set(int value);
string getPip();
string getSuit();
void print();
private:
int m_cardValue;
};
#endif


Deck.cpp:


#include "deck.h"
Deck::Deck() //--- default class constructor
{ srand(time(0));
for (int i=0; i < 52;="">
{Card cardInstance;
cardInstance.set(i)
m_undealtDeck.push_back(cardInstance); // should it be .get here()???
}
}
void Deck::reset()
{ while (getSizeDealtDeck() != 0)
{

int last_index = getSizeDealtDeck()-1;
m_undealtDeck.push_back(m_dealtDeck[last_index]);
m_dealtDeck.pop_back();
}
}
Card Deck::dealCard() // --- Deal a single card
{ int random_index = rand() % getSizeUndealtDeck(); // gets random index in undealt deck
Card random_card; // creates a card instance
random_card.set(m_undealtDeck[random_index].get()); // set the random card to the correct value
m_dealtDeck.push_back(random_card); // pushes the random card to the dealt deck
m_undealtDeck[random_index] = m_undealtDeck.back(); // puts the back index value to the random index
m_undealtDeck.pop_back(); // gets rid of the back value
return random_card;
const int Deck::getSizeUndealtDeck() // --- return size of undealt deck
{ return m_undealtDeck.size();
}
const int Deck::getSizeDealtDeck() // --- return size of dealt deck
{ return m_dealtDeck.size();
}
void Deck::printUndealtDeck() // loops through the undealt deck and prints it
{
for (int i=0; i < getsizeundealtdeck();="">
{
m_undealtDeck[i].print();
cout <>
}
}
void Deck::printDealtDeck() // loops through the dealt deck
{
for (int i=0; i < getsizedealtdeck();="">
{
m_dealtDeck[i].print();
cout <>
}
}


Hand.cpp:


#include "pokerHand.h"
void Hand::newCard(Deck& deck, int location)
{
Card new_card = deck.dealCard();
m_hand[location] = new_card;
}
void Hand::newHand(Deck& deck)
{
for (int i=0; i < num_cards_on_hand;="">
{
Hand::newCard(deck, i);
}
}
void Hand::exchangeCards(Deck& deck)
{
int num_of_exchanges;
cout < "how="" many="" cards="" would="" you="" like="" to="" exchange="" (1-5):="" ";="" gets="" number="" of="" cards="" to="" be="">
cin >> num_of_exchanges;
while (num_of_exchanges > 5 || num_of_exchanges < 1)="" validates="">
{
cout < "please="" enter="" a="" number="" (1-5):="">
cin >> num_of_exchanges;
}
for (int i=0; i < num_of_exchanges;="" i++)="" looping="" through="" number="" of="">
{
int position = i; // positioned to be changed is i
if (num_of_exchanges != NUM_CARDS_ON_HAND) // if number of exchanges is less than total hand count
{
cout < "enter="" a="" position="" in="" hand="" of="" card="" to="" exchange:="">
cin >> position; // gets position to be replaced
while (position > 5 || position < 1)="" validates="">
{
cout < "please="" enter="" a="" number="" (1-5):="">
cin >> position;
}
position--;
}
Hand::newCard(deck, position); // replaces card at position
}
}
void Hand::print()
{
for (int i=0; i < num_cards_on_hand;="">
{
cout < "card="" "="">< i+1="">< "="" is="" the="">
m_hand[i].print();
cout <>
}
}


H *main.cpp - Code:Blocks 20.03<br>File Edit View Search Project Build<br>Debug Fortran wxSmith ITools Tools+ Plugins DoxyBlocks Settings Help<br>D E G: A C: II X<br>E C:<br>E <global><br>v main0 : int<br>** *<<br>Q Q S C<br>Start here X *deck.cpp x *hand.cpp x *main.cpp x *deck.h x *hand.h X *card.h x *card.cpp x<br>32<br>while (exchangeCards !=

Extracted text: H *main.cpp - Code:Blocks 20.03 File Edit View Search Project Build Debug Fortran wxSmith ITools Tools+ Plugins DoxyBlocks Settings Help D E G: A C: II X E C: E v main0 : int ** *< q="" q="" s="" c="" start="" here="" x="" *deck.cpp="" x="" *hand.cpp="" x="" *main.cpp="" x="" *deck.h="" x="" *hand.h="" x="" *card.h="" x="" *card.cpp="" x="" 32="" while="" (exchangecards="" !="y" &&="" exchangecards="" !="y" &&="" exchangecards="" !="X" &&="" exchangecards="" !="n" )="" 33="" {="" 34="" cout="">< "please="" enter="" y="" or="" n="" only:="" ";="" 35="" getline="" (cin,="" exchangecards);="" 36="" }="" 37="" ||="" exchangecards="=" "y")="" 38="" {="" 39="" myhand.exchangecards="" (mydeck)="" ;="" 40="" 41="" cout="">< endl;="" 42="" myhand.print="" ();="" 43="" cout="">< endl;="" 44="" o="" resets="" the="" deck="" for="" a="" new="" game="" mydeck.reset="" ();="" cout="">< "play="" again?="" [y="" n]:="" ";="" getline="" (cin,="" repeat);="" 45="" 46="" 47="" while="" (repeat="" !-="" "y"="" &&="" repeat="" !="y" &&="" repeat="" !="N" &&="" repeat="" !="n" )="" 48="" {="" 49="" cout="">< "please enter y or n only: "; 50 getline (cin, repeat); logs & others 1 2 cccc x ở build log x build messages x cppcheck/vera++ x 2 cppcheck/vera++ messages x cscope x debugger x 2 doxyblocks x f fortran info x t closed files list x o thread file line message === build file: "no target" in "no project" (compiler: unknown) === c:\users\mica... in function 'int main ()': c:\users\mica... 44 error: 'resetdeck' was not declared in this scope === build failed: 1 error (s), 0 warning (s) (0 minute (s), 2 second (s)) === %3%d3d3d c:\users\micai\documents\assignment2\main.cpp c/c++ windows (cr+lf) windows-1252 line 45, col 25, pos 1199 insert modified read/write default "please="" enter="" y="" or="" n="" only:="" ";="" 50="" getline="" (cin,="" repeat);="" logs="" &="" others="" 1="" 2="" cccc="" x="" ở="" build="" log="" x="" build="" messages="" x="" cppcheck/vera++="" x="" 2="" cppcheck/vera++="" messages="" x="" cscope="" x="" debugger="" x="" 2="" doxyblocks="" x="" f="" fortran="" info="" x="" t="" closed="" files="" list="" x="" o="" thread="" file="" line="" message="==" build="" file:="" "no="" target"="" in="" "no="" project"="" (compiler:="" unknown)="==" c:\users\mica...="" in="" function="" 'int="" main="" ()':="" c:\users\mica...="" 44="" error:="" 'resetdeck'="" was="" not="" declared="" in="" this="" scope="==" build="" failed:="" 1="" error="" (s),="" 0="" warning="" (s)="" (0="" minute="" (s),="" 2="" second="" (s))="==" %3%d3d3d="" c:\users\micai\documents\assignment2\main.cpp="" c/c++="" windows="" (cr+lf)="" windows-1252="" line="" 45,="" col="" 25,="" pos="" 1199="" insert="" modified="" read/write="">
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here