The answer you are giving me over and over again doesn't make sense and it's the same code that doesn't compile!

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

The error is in line 52.

It should be ( update line 52 with )  if ( exchangeCards == "Y" || exchangeCards == "y" )"

 

This is the answer you gave me the last time. I need line 62! The answer you are giving me over and over again doesn't make sense and it's the same code that doesn't compile!

Main.cpp

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <sstream>
#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 << 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;
}

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:
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<Card> m_undealtDeck; // Undealt cards
vector<Card> m_dealtDeck; // Dealt cards
};
#endif

hand.h:

#ifndef HAND_H
#define HAND_H
#include <iostream>
#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 <iostream>
#include <string>
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

 

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; i++)
{
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 exchanged
cin >> num_of_exchanges;
while (num_of_exchanges > 5 || num_of_exchanges < 1) // validates input
{
cout << "Please enter a number (1-5): ";
cin >> num_of_exchanges;
}
for (int i=0; i < num_of_exchanges; i++) // looping through number of exchanges
{
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 input
{
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; i++)
{cout << "Card " << i+1 << " is the ";
m_hand[i].print();
cout << endl;
}} 

 

A main.cpp - Code:Blocks 20.03
X
File Edit View Search Project Build Debug Fortran wxSmith
Tools Tools+ Plugins DoxyBlocks Settings Help
/** *<
S C
| <global>
vmain) : int
Management
Start here X main.cpp x deck.cpp X
Projects
FSymbols
Files
string repeat = "Y";
Deck myDeck;
29
Workspace
30
31
Hand myHand;
32
string exchangeCards;
33
34
while (repeat == "Y" || repeat == "y")
35
36
cout << endl;
37
38
myHand.newHand (myDeck) ;
myHand.print ();
cout << endl;
39
40
41
42
cout << "Would you like to exchange any cards? [Y / N]: ";
43
getline (cin, exchangeCards);
44
45
while (exchangeCards != "y" && exchangeCards != "y" && exchangeCards != "X" && exchangeCards != "n")
46
{
47
cout << "Please enter Y or N only: ";
48
getline (cin, exchangeCards);
49
50
51
52
if (exchangeCards == "y" || exchangeCards == "y")
53
{
54
myHand.exchangeCards (myDeck) ;
55
56
cout << endl;
57
58
myHand.print ();
cout << endl;
61
62 O
myDeck.reset () ;
// Resets the deck for a new game
63
cout << "Play again? [Y / N]: ";
getline (cin, repeat);
64
65
Logs & others
2 Code:Blocks x
Q Search results X
A Cccc X
Ở Build log X
P Build messages x CppCheck/Vera++ X 2 CppCheck/Vera++ messages X Cscope X
Z DoxyBlocks X
F Fortran info x
Closed files list X
Q Thread search x
File
Line
Message
=== Build file: "no target" in "no project" (compiler: unknown)
===
C:\Users\cccc...
In function 'int main ()':
C:\Users\ccee...
62
error: 'class Deck' has no member named 'reset'; did you mean 'resetDeck'?
=== Build failed: 1 error (s), 0 warning (s) (0 minute (s), 0 second (s)) ===
C:\Users\cccccc\Documents\Assignment 2\main.cpp
C/C++
Windows (CR+LF)
WINDOWS-1252 Line 59, Col 1, Pos 1497
Insert
Read/Write default
Transcribed Image Text:A main.cpp - Code:Blocks 20.03 X File Edit View Search Project Build Debug Fortran wxSmith Tools Tools+ Plugins DoxyBlocks Settings Help /** *< S C | <global> vmain) : int Management Start here X main.cpp x deck.cpp X Projects FSymbols Files string repeat = "Y"; Deck myDeck; 29 Workspace 30 31 Hand myHand; 32 string exchangeCards; 33 34 while (repeat == "Y" || repeat == "y") 35 36 cout << endl; 37 38 myHand.newHand (myDeck) ; myHand.print (); cout << endl; 39 40 41 42 cout << "Would you like to exchange any cards? [Y / N]: "; 43 getline (cin, exchangeCards); 44 45 while (exchangeCards != "y" && exchangeCards != "y" && exchangeCards != "X" && exchangeCards != "n") 46 { 47 cout << "Please enter Y or N only: "; 48 getline (cin, exchangeCards); 49 50 51 52 if (exchangeCards == "y" || exchangeCards == "y") 53 { 54 myHand.exchangeCards (myDeck) ; 55 56 cout << endl; 57 58 myHand.print (); cout << endl; 61 62 O myDeck.reset () ; // Resets the deck for a new game 63 cout << "Play again? [Y / N]: "; getline (cin, repeat); 64 65 Logs & others 2 Code:Blocks x Q Search results X A Cccc X Ở Build log X P Build messages x CppCheck/Vera++ X 2 CppCheck/Vera++ messages X Cscope X Z DoxyBlocks X F Fortran info x Closed files list X Q Thread search x File Line Message === Build file: "no target" in "no project" (compiler: unknown) === C:\Users\cccc... In function 'int main ()': C:\Users\ccee... 62 error: 'class Deck' has no member named 'reset'; did you mean 'resetDeck'? === Build failed: 1 error (s), 0 warning (s) (0 minute (s), 0 second (s)) === C:\Users\cccccc\Documents\Assignment 2\main.cpp C/C++ Windows (CR+LF) WINDOWS-1252 Line 59, Col 1, Pos 1497 Insert 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
Linux
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
  • SEE MORE 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