Class card {
int num;
char suit;
public:
void setNum(int n) {
assert(n >= 1 && n <= 13);
num = n;
}
void setSuit(char s) {
assert(s == \'C\' || s == \'D\' || s == \'H\' || s == \'S\');
suit = s;
}
int getNum() {
assert(num >= 1 && num <= 13);
return num;
}
char getSuit() {
assert(suit == \'C\' || suit == \'D\' || suit == \'H\' || suit == \'S\');
return suit;
}
string read() {
string output=\"\";
if (num == 1) {
output= \"Ace\";
}
else if (num == 11) {
output = \"Jack\";
}
else if (num == 12) {
output = \"Queen\";
}
else if (num == 13) {
output = \"King\";
}
else {
output = getNum();
}
output += \" of \";
if (suit == \'C\') {
output += \"Clubs\";
}
else if (suit == \'D\') {
output += \"Diamonds\";
}
else if (suit == \'H\') {
output += \"Hearts\";
}
else if (suit == \'S\') {
output += \"Spades\";
}
return output;
}
card(){
num = 0;
suit = \'X\';
}
card (int n, char s) {
setNum(n);
setSuit(s);
};
void setNum(int n) {
assert(n >= 1 && n <= 13);
num = n;
}
void setSuit(char s) {
assert(s == \'C\' || s == \'D\' || s == \'H\' || s == \'S\');
suit = s;
}
int getNum() {
assert(num >= 1 && num <= 13);
return num;
}
char getSuit() {
assert(suit == \'C\' || suit == \'D\' || suit == \'H\' || suit == \'S\');
return suit;
}
string read() {
string output=\"\";
if (num == 1) {
output= \"Ace\";
}
else if (num == 11) {
output = \"Jack\";
}
else if (num == 12) {
output = \"Queen\";
}
else if (num == 13) {
output = \"King\";
}
else {
output = getNum();
}
output += \" of \";
if (suit == \'C\') {
output += \"Clubs\";
}
else if (suit == \'D\') {
output += \"Diamonds\";
}
else if (suit == \'H\') {
output += \"Hearts\";
}
else if (suit == \'S\') {
output += \"Spades\";
}
return output;
}
card(){
num = 0;
suit = \'X\';
}
card (int n, char s) {
setNum(n);
setSuit(s);
};
Problem 3: (Hand) Write the member function implementations for the class hand, which simulates a hand of 2 cards, into the file hand .cpp. The relative strength of 2 hands are determined by the following rules: A pair (two cards of the same number) is the strongest hand. Two cards of the same suit is the next strongest hand. Two cards of different numbers and suits is the weakest hand. Within the same kind of hands, the stronger land is determined by the larger number. If two hands are of the same kind and largest numbers are the same, the stronger hand is determined by the smaller number. If all above fails, the two hands are of equal strength. Le all suits are of equal strength. 2 is the weakest number. An Ace is stronger than a King. Here are some examples: 3 is stronger than 9A24. 9A2A is stronger than 8 7 8 7 is stronger than 8 6 8 is stronger than A J 3 has the same strength as 3 The public data members card cl, c2 represent the 2 cards of a hand. The public member function bool operator
Class card {
int num;
char suit;
public:
void setNum(int n) {
assert(n >= 1 && n <= 13);
num = n;
}
void setSuit(char s) {
assert(s == \'C\' || s == \'D\' || s == \'H\' || s == \'S\');
suit = s;
}
int getNum() {
assert(num >= 1 && num <= 13);
return num;
}
char getSuit() {
assert(suit == \'C\' || suit == \'D\' || suit == \'H\' || suit == \'S\');
return suit;
}
string read() {
string output=\"\";
if (num == 1) {
output= \"Ace\";
}
else if (num == 11) {
output = \"Jack\";
}
else if (num == 12) {
output = \"Queen\";
}
else if (num == 13) {
output = \"King\";
}
else {
output = getNum();
}
output += \" of \";
if (suit == \'C\') {
output += \"Clubs\";
}
else if (suit == \'D\') {
output += \"Diamonds\";
}
else if (suit == \'H\') {
output += \"Hearts\";
}
else if (suit == \'S\') {
output += \"Spades\";
}
return output;
}
card(){
num = 0;
suit = \'X\';
}
card (int n, char s) {
setNum(n);
setSuit(s);
};