#include #include #include #include #include "card.h" #include "deck.h" #include "hand.h" using namespace N; using namespace std; /**main() controls the operation of the program*/ int main()

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

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <sstream>

#include "card.h"
#include "deck.h"
#include "hand.h"

using namespace N;

using namespace std;

/**main()

controls the operation of the program*/

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.cpp

#include "card.h"

/**void Card::get()

Defining a function from outside of a class to access a static variable within a class.

Card is the class name and get() is the idenifier or function name.

this function will receive the card value*/

// get() --- Get card value
// - return the value from the member variable
void Card::get()
{
return m_cardValue;
}

/**void Card::set()

Defining a function from outside of a class to access a static variable within a class.

Card is the class name and set() is the idenifier or function name.

this function will set the card value */

// set() --- Set card value
// - set the value of the member variable
void Card::set(int newCardVal)
{
m_cardValue = newCardVal;
}

/**void Card::getPip()

Defining a function from outside of a class to access a static variable within a class.

Card is the class name and getPip() is the idenifier or function name.

this function will return the pip value of the cards*/

string Card::getPip()
{
return pips[m_cardValue % 13];
}

/**void Card::getSuit()

Defining a function from outside of a class to access a static variable within a class.

Card is the class name and getSuit() is the idenifier or function name.

this function will return the suit value of the cards*/

string Card::getSuit()
{
return suits[m_cardValue / 13];
}

/**void Card::print()

Defining a function from outside of a class to access a static variable within a class.

Card is the class name and print() is the idenifier or function name.

this function will return the suit value of the cards*/

// print() --- Print card value
// - print the card's value
// - Example display if member variable m_cardValue is 0
// - it should print "Ace of Hearts"
void Card::print()
{
int suit_number = m_cardValue / 13;
int pip_number = m_cardValue % 13;

cout << pips[pip_number] << " of " << suits[suit_number];

}

//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

Add these features to the poker game:

  • Multilevel Inheritance with polymorphism and includes at least one abstract class.
  • Dynamic memory (new, delete) using pointers within a class.
  • At least one template class.
  • At least one operator overloading.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Mathematical functions
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