-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.cpp
More file actions
55 lines (49 loc) · 1016 Bytes
/
Card.cpp
File metadata and controls
55 lines (49 loc) · 1016 Bytes
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
#include "Card.h"
#include <string>
bool Card::beats_in_suit_of(const Card& lead) const
{
return (suit == lead.suit) && (value > lead.value);
}
const std::string Card::str() const
{
/** string representation of card
both 1 and 14 are Ace */
std::string to_return;
switch (value)
{
case 1:
case 14:
to_return = "Ace of ";
break;
case 11:
to_return = "Jack of ";
break;
case 12:
to_return = "Queen of ";
break;
case 13:
to_return = "King of ";
break;
default:
to_return = std::to_string(value);
to_return += " of ";
}
switch (suit)
{
case CLUBS:
to_return += "Clubs";
break;
case DIAMONDS:
to_return += "Diamonds";
break;
case SPADES:
to_return += "Spades";
break;
case HEARTS:
to_return += "Hearts";
break;
default:
to_return += "UNKNOWN SUIT";
}
return to_return;
}