-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.cpp
41 lines (31 loc) · 930 Bytes
/
Card.cpp
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
//*****************************************************************
// Deck_cards.cpp
//
// Written by George Liao on Jan 25, 2016.
//
//*****************************************************************
#include <iostream>
#include <string>
using namespace std;
enum Suit {Diamonds, Clubs, Hearts, Spades};
enum Rank {TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE};
//enum should be able to facilitate the cards comparison
class Card
{
Suit suit;
Rank rank;
public:
Card(Rank card_rank, Suit card_suit);
Card(){}
void print() const;
};
Card::Card(Rank card_rank, Suit card_suit):
suit(card_suit),
rank(card_rank)
{
}
void Card::print() const{
string ranks[] = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
string suits[] = {"Diamonds", "Clubs", "Hearts", "Spades"};
cout << ranks[rank] + " of " + suits[suit] << std::endl;
}