Hey Guys ! i have a question related to classes ..
s played using the standard French deck with 52 cards. Each card is from one of the 4 suits, clubs (♣), diamonds (♦), hearts (♥) and spades (♠). Each suit includes 13 cards which are ranked as A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3 and 2.
Make a class called Card. Each card is represented by a suit and a rank. You can keep both as strings. Implement getters and setters for the Card class as well as a print function. A 7 of spades should be printed as 7S or 7♠.
Create a class Deck which contains 52 cards.
I am unable to understand to understand the last line in the question ..
So far i have written this much code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#include <iostream>
#include<string>
using namespace std;
class Card
{
public :
string suit ;
string rank ;
void Setsuit(string Suit)
{
suit = Suit ;
}
string GetSuit ()
{
return suit ;
}
void SetRank( string Rank)
{
rank = Rank ;
}
string GetRank ()
{
return rank ;
}
/*void print()
{
}*/
};
#include <iostream>
#include <iomanip>
#include <string>
#include"q1.h"
using namespace std;
class Deck
{
public :
Deck()
{
string Card[52];
}
void Print_Cards_in_Deck()
{
for (int i = 0 ; i<52; i++ )
{
if (i==0 || i<13)
{
cout << setw(2);
Card[i] = '\x03' ;
cout << Card[i] ;
cout << endl;
}
else if (i>=13 && i<26)
{
cout << setw(2);
Card[i] = '\x04' ;
cout << Card[i] ;
cout << endl;
}
else if (i>26 && i<=39)
{
cout << setw(2);
Card[i] = '\x05' ;
cout << Card[i] << endl;
}
else if (i>=38 && i<=52)
{
cout << setw(2);
Card[i] = '\x06' ;
cout << Card[i] << endl;
}enter code here
}
};
|
How do i make a deck of 52 cards ? thats the major issue .. please somenone help me with this ..