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 *

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

H *main.cpp - Code:Blocks 20.03
File Edit View Search Project Build Debug Fortran wxSmith Tools Tools+ Plugins DoxyBlocks Settings Help
> E G: 4: A G: II E
E C:
团
| <global>
v main0 : int
/** *<
+ + 2 Aa *
Q Q S C
Management
Start here x *main.cpp x card.h X deck.h x hand.h Xx
•
Projects Files
FSymbols
|| exchangeCards == "y")
52
if(exchangeCards
== "y"
Workspace
53
54
myHand.exchangeCards (myDeck) ;
55
56
cout << endl;
57
58
myHand.print ();
59
60
cout << endl;
61
62 D
myDeck.reset (); // Resets the deck for a new game
63
cout << "Play again? [Y / N]: ";
getline (cin, repeat);
while (repeat != "Y" && repeat != "y" && repeat != "N" && repeat != "n")
64
65
66
67
{
68
cout << "please enter Y or N only: ";
69
getline (cin, repeat);
70
Logs & others
A Code:Blocks X
Search results x Cccc >x
Build log X
Build messages X CppCheck/Vera++ X CppCheck/Vera++ messages X Cscope X
Debuggl
File
Line
Message
=== Build file: "no target" in "no project" (compiler: unknown)
===
C:\Users\Mica...
In function 'int main ()':
C:\Users\Mica...
62
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\Downloads\Assignment2\main.cpp
C/C++
Windows (CR+LF)
WINDOWS-1252 Line 55, Col 10, Pos 1444
Insert
Modified
Read/Write
default
Transcribed Image Text:H *main.cpp - Code:Blocks 20.03 File Edit View Search Project Build Debug Fortran wxSmith Tools Tools+ Plugins DoxyBlocks Settings Help > E G: 4: A G: II E E C: 团 | <global> v main0 : int /** *< + + 2 Aa * Q Q S C Management Start here x *main.cpp x card.h X deck.h x hand.h Xx • Projects Files FSymbols || exchangeCards == "y") 52 if(exchangeCards == "y" Workspace 53 54 myHand.exchangeCards (myDeck) ; 55 56 cout << endl; 57 58 myHand.print (); 59 60 cout << endl; 61 62 D myDeck.reset (); // Resets the deck for a new game 63 cout << "Play again? [Y / N]: "; getline (cin, repeat); while (repeat != "Y" && repeat != "y" && repeat != "N" && repeat != "n") 64 65 66 67 { 68 cout << "please enter Y or N only: "; 69 getline (cin, repeat); 70 Logs & others A Code:Blocks X Search results x Cccc >x Build log X Build messages X CppCheck/Vera++ X CppCheck/Vera++ messages X Cscope X Debuggl File Line Message === Build file: "no target" in "no project" (compiler: unknown) === C:\Users\Mica... In function 'int main ()': C:\Users\Mica... 62 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\Downloads\Assignment2\main.cpp C/C++ Windows (CR+LF) WINDOWS-1252 Line 55, Col 10, Pos 1444 Insert Modified Read/Write default
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education