//this class stores the face values and suits of the cards andreturns the names
ID: 3616886 • Letter: #
Question
//this class stores the face values and suits of the cards andreturns the names
#include <iostream>
#include <string>
#include <vector>
using namespace std;
Class Card
{
public:
static const intface = 13;
static const intsuit = 4;
Card(int, int); // constructorthat receives two int values representing # of facevalues
//and suit values and initializes the data members
string toString(); // return the card as astring in the form "Face of Suit"
private:
string faceNames[face]; // array of cardface values
string suitNames[suit]; // array of cardsuits
};
//initialize Card arrays
const string Card::faceNames[face]= {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};
const string Card::suitNames[suit]= {"Clubs", "Diamonds", "Hearts", "Spades"};
//end Class Card
Explanation / Answer
please rate - thanks I made just a few changes/corrections should get you going // this class stores the face values and suits of the cards andreturns the names #include #include #include using namespace std; class Card { public: static const int facecount = 13; static const int suitcount = 4; static const string faceNames[facecount]; // array of card facevalues static const string suitNames[suitcount]; // array of cardsuits Card(int f, int s) // constructor that receives two int valuesrepresenting # of face values {face=f; suit=s; } // and suit values and initializes the data members string toString() // return the card as a string in the form "Faceof Suit" {return faceNames[face-1]+" of "+suitNames[suit-1]; } private: int face; int suit; }; // initialize Card arrays const string Card::faceNames[facecount] = {"Ace", "2", "3", "4","5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}; const string Card::suitNames[suitcount] = {"Clubs", "Diamonds","Hearts", "Spades"}; // end Class Card int main() {Card hand(8,2); coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.