-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.cpp
38 lines (33 loc) · 841 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
#include "Card.h"
Card::Card(int rank, Color color) {
// had to use scope resolution because the var names conflict
Card::rank = rank;
Card::color = color;
// if card is purple value is rank
// if card is orange, value is rank times two
if (color == purple)
value = rank;
else
value = rank*2;
}
// returns the formatted output string of the card
std::string Card::printCard() {
std::stringstream ss;
std::string colorString;
// map enum values to strings
if (color == 0)
colorString = "purple";
else
colorString = "orange";
ss << colorString << ":" << rank;
return ss.str();
}
int Card::getRank() {
return rank;
}
Card::Color Card::getColor() {
return color;
}
int Card::getValue() {
return value;
}