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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
int main()
{
int suit1, suit2, suit3, suit4, suit5;
int face1, face2, face3, face4, face5;
cout << "Enter a hand (10 integers): " << flush;
cin >> suit1 >> face1 >> suit2 >> face2 >> suit3 >> face3 >> suit4 >> face4 >> suit5 >> face5;
Card card1, card2, card3, card4, card5;
card1.set(suit1,face1);
card2.set(suit2,face2);
card3.set(suit3,face3);
card4.set(suit4,face4);
card5.set(suit5,face5);
card1.display();
card2.display();
card3.display();
card4.display();
card5.display();
Hand hand;
hand.set(card1, card2, card3, card4, card5);
hand.displayHand();
system("pause");
return 0;
}
void Card::set(int newSuit, int newFace)
{
suit = newSuit;
face = newFace;
}
void Card::display()
{
string faceStr;
switch (face)
{
case 2: faceStr = "2";
break;
case 3: faceStr = "3";
break;
case 4: faceStr = "4";
break;
case 5: faceStr = "5";
break;
case 6: faceStr = "6";
break;
case 7: faceStr = "7";
break;
case 8: faceStr = "8";
break;
case 9: faceStr = "9";
break;
case 10: faceStr = "10";
break;
case 11: faceStr = "Jack";
break;
case 12: faceStr = "Queen";
break;
case 13: faceStr = "King";
break;
case 14: faceStr = "Ace";
break;
}
string suitStr = "";
switch (suit)
{
case 0: suitStr = "Clubs";
break;
case 1: suitStr = "Spades";
break;
case 2: suitStr = "Hearts";
break;
case 3: suitStr = "Diamonds";
break;
}
cout << faceStr << " of " << suitStr << endl;
}
void Hand::set(Card newCard1, Card newCard2, Card newCard3, Card newCard4, Card newCard5)
{
card1 = newCard1;
card2 = newCard2;
card3 = newCard3;
card4 = newCard4;
card5 = newCard5;
}
void Hand::displayHand()
{
cout << "*********************" << endl;
card1.display();
card2.display();
card3.display();
card4.display();
card5.display();
cout << "*********************" << endl;
}
|