-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.hpp
96 lines (77 loc) · 2.51 KB
/
Card.hpp
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
#ifndef Card_hpp
#define Card_hpp
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <string>
#include <array>
#include <vector>
#include <algorithm>
using namespace std;
class Card {
public:
// rank names
static constexpr const char* const RANK_TWO = "Two";
static constexpr const char* const RANK_THREE = "Three";
static constexpr const char* const RANK_FOUR = "Four";
static constexpr const char* const RANK_FIVE = "Five";
static constexpr const char* const RANK_SIX = "Six";
static constexpr const char* const RANK_SEVEN = "Seven";
static constexpr const char* const RANK_EIGHT = "Eight";
static constexpr const char* const RANK_NINE = "Nine";
static constexpr const char* const RANK_TEN = "Ten";
static constexpr const char* const RANK_JACK = "Jack";
static constexpr const char* const RANK_QUEEN = "Queen";
static constexpr const char* const RANK_KING = "King";
static constexpr const char* const RANK_ACE = "Ace";
// suit names
static constexpr const char* const SUIT_SPADES = "Spades";
static constexpr const char* const SUIT_HEARTS = "Hearts";
static constexpr const char* const SUIT_CLUBS = "Clubs";
static constexpr const char* const SUIT_DIAMONDS = "Diamonds";
// Card ctor
// EFFECTS: initializes card to Two of Spades
Card();
// REQUIRES: valid rank, valid suit
// Initializes card to inputted rank and suit
Card(const string &rank_in, const string &suit_in);
// EFFECTS: returns rank
string get_rank() const;
// EFFECTS: returns suit
string get_suit() const;
// EFFECTS: returns true if card is a non-ace face card (Jack, Queen or King)
bool is_face() const;
// EFFECTS: return true if card is an ace card
bool is_ace() const;
private:
string rank;
string suit;
};
// EFFECTS: prints name of Card to os
ostream & operator<<(ostream &os, const Card &card);
// EFFECTS: puts all suits into an array
constexpr const char* const SUIT_ARRAY[] = {
Card::SUIT_SPADES,
Card::SUIT_HEARTS,
Card::SUIT_CLUBS,
Card::SUIT_DIAMONDS
};
// EFFECTS: puts all ranks into an array
constexpr const char* const RANK_ARRAY[] = {
Card::RANK_TWO,
Card::RANK_THREE,
Card::RANK_FOUR,
Card::RANK_FIVE,
Card::RANK_SIX,
Card::RANK_SEVEN,
Card::RANK_EIGHT,
Card::RANK_NINE,
Card::RANK_TEN,
Card::RANK_JACK,
Card::RANK_QUEEN,
Card::RANK_KING,
Card::RANK_ACE
};
const int NUM_SUITS = 4;
const int NUM_RANKS = 13;
#endif /* Card_hpp */