-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.cpp
133 lines (128 loc) · 2.09 KB
/
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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "Card.h"
#include <iostream>
using namespace std;
/* Default Constructor */
Card::Card()
{
suit = SPADES;
value = ACE;
}
/* Overloaded Constructor */
Card::Card(Suit suit, Value value)
{
this->suit = suit;
this->value = value;
}
/* getSuit */
//Returns suit enumerated type
Suit Card::getSuit()
{
return suit;
}
/* getValue */
//Returns value enumerated type
Value Card::getValue()
{
return value;
}
/* toString */
//Returns the card in string form
string Card::toString()
{
string suitString;
string valueString;
switch(suit)
{
case 1:
suitString = "Spades";
break;
case 2:
suitString = "Hearts";
break;
case 3:
suitString = "Diamonds";
break;
case 4:
suitString = "Clubs";
break;
}
switch(value)
{
case 2:
valueString = "Duece";
break;
case 3:
valueString = "Tres";
break;
case 4:
valueString = "Four";
break;
case 5:
valueString = "Five";
break;
case 6:
valueString = "Six";
break;
case 7:
valueString = "Seven";
break;
case 8:
valueString = "Eight";
break;
case 9:
valueString = "Nine";
break;
case 10:
valueString = "Ten";
break;
case 11:
valueString = "Jack";
break;
case 12:
valueString = "Queen";
break;
case 13:
valueString = "King";
break;
case 14:
valueString = "Ace";
break;
}
return valueString + " of " + suitString;
}
/* getValueString */
//Returns just the value of the string
string Card::getValueString()
{
switch(value)
{
case 2:
return "Deuce";
case 3:
return "Trey";
case 4:
return "Four";
case 5:
return "Five";
case 6:
return "Six";
case 7:
return "Seven";
case 8:
return "Eight";
case 9:
return "Nine";
case 10:
return "Ten";
case 11:
return "Jack";
case 12:
return "Queen";
case 13:
return "King";
case 14:
return "Ace";
default:
return "Error!";
}
}