Code:
#include <iostream>
#include "Hand.h"
using namespace std;
/*
Hand class: This class defines a hand of 5 poker cards.
Types: (1 = Diamonds), (2 = Hearts), (3 = Spades), (4 = Clubs)
Value: (1 = Ace), 2, 3, 4, 5, 6, 7, 8, 9, 10, (11 = Jack), (12 = Queen), (13 = King)
*/
// Constructor
Hand::Hand(void)
{
int x;
for (x = 0; x < 5; x++) {
cards[x] = Card();
}
}
// Set the card at a given index.
void Hand::setCard(int index, Card charizard) {
cards[index] = charizard;
}
// Return the card at a given index.
Card Hand::getCard(int index) {
return cards[index];
}
// Print the hand graphically.
void Hand::printHand() {
int x;
cout << "***** ***** ***** ***** *****\n";
//////////////////
for (x = 0; x < 5; x++) {
if ((cards[x].getValue() <= 9) && (cards[x].getValue() >= 2)) {
cout << "*" << cards[x].getValue() << " * ";
}
else if (cards[x].getValue() == 10) {
cout << "*10 * ";
}
else if (cards[x].getValue() == 11) {
cout << "*J * ";
}
else if (cards[x].getValue() == 12) {
cout << "*Q * ";
}
else if (cards[x].getValue() == 13) {
cout << "*K * ";
}
else {
cout << "*A * ";
}
}
cout << "\n";
//////////////////
for (x = 0; x < 5; x++) {
if (cards[x].getType() == 1) { cout << "* /\\* "; }
else if (cards[x].getType() == 2) { cout << "* ^^* "; }
else if (cards[x].getType() == 3) { cout << "* /\\* "; }
else { cout << "* o * "; }
}
cout << "\n";
//////////////////
for (x = 0; x < 5; x++) {
if (cards[x].getType() == 3) { cout << "* ][* "; }
else if (cards[x].getType() == 4) { cout << "*o:o* "; }
else { cout << "* \\/* "; }
}
cout << "\n";
//////////////////
cout << "***** ***** ***** ***** *****\n\n";
}