-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcards.h
102 lines (80 loc) · 2.35 KB
/
cards.h
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
/* *************************************
Elias deFaria, February 26, 2015
Interface of a simple Card class
************************************* */
#include <string>
#include <vector>
#include <fstream>
#ifndef CARDS_H
#define CARDS_H
using namespace std;
enum suit_t {OROS, COPAS, ESPADAS, BASTOS};
/*
The values for this type start at 0 and increase by one
afterwards until they get to SIETE.
The rank reported by the function Card::get_rank() below is
the value listed here plus one.
E.g:
The rank of AS is reported as static_cast<int>(AS) + 1 = 0 + 1 = 1
The rank of SOTA is reported as static_cast<int>(SOTA) + 1 = 9 + 1 = 10
*/
enum rank_t {AS, DOS, TRES, CUATRO, CINCO, SEIS, SIETE, SOTA=9, CABALLO=10, REY=11};
class Player;
class Card {
public:
// Constructor assigns random rank & suit to card.
Card();
// Accessors
string get_spanish_suit() const;
string get_spanish_rank() const;
/*
These are the only functions you'll need to code
for this class. See the implementations of the two
functions above to get an idea of how to proceed.
*/
string get_english_suit() const;
string get_english_rank() const;
// Converts card rank to number.
// The possible returns are: 1, 2, 3, 4, 5, 6, 7, 10, 11 and 12
int get_rank() const;
double get_value() const;
// Compare rank of two cards. E.g: Eight<Jack is true.
// Assume Ace is always 1.
// Useful if you want to sort the cards.
bool operator < (Card card2) const;
private:
suit_t suit;
rank_t rank;
};
class Hand {
public:
// A vector of Cards
//Default Constructor
Hand() : bust(false){
Card a;
cards.push_back(a);
value = a.get_value();
}
void hit();
bool get_bust() const;
double get_value() const;
vector<Card> get_cards() const;
private:
vector<Card> cards;
double value;
bool bust;
};
class Player {
public:
// Constructor.
// Assigns initial amount of money
Player() : money(100){}
Player(int m) : money(m){}
// You decide what functions you'll need...
int get_money() const;
void change_money(int n);
private:
int money;
// You decide what extra fields (if any) you'll need...
};
#endif