-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.cpp
More file actions
151 lines (138 loc) · 2.06 KB
/
Card.cpp
File metadata and controls
151 lines (138 loc) · 2.06 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include "Card.h"
Card::Card(int num, Color c)
{
number = num;
theColor = c;
colorChangedTo = c;
if (theColor == BLACK)
{
points = 50;
}
else
{
if (number >= 10)
{
points = 20;
}
else
{
points = number;
}
}
}
Card::Card()
{
}
int Card::getNumber()
{
return number;
}
Color Card::getColor()
{
return theColor;
}
Color Card::getColorChange()
{
return colorChangedTo;
}
void Card::setColorChange(Color newc)
{
colorChangedTo = newc;
}
int Card::getPoints()
{
return points;
}
bool Card::operator==(Card& other)
{
return other.theColor == theColor && other.number == number;
}
string cardTOString(Card c)
{
string toReturn = "";
if (c.getColor() == BLUE || c.getColor() == RED || c.getColor() == GREEN || c.getColor() == YELLOW)
{
switch (c.getColor())
{
case BLUE:
toReturn += "Blu";
break;
case RED:
toReturn += "Red";
break;
case GREEN:
toReturn += "Gre";
break;
case YELLOW:
toReturn += "Yel";
break;
}
if (c.getNumber() >= 0 && c.getNumber() <= 9)
{
if (c.getNumber() == 0)
{
toReturn += "0";
}
if (c.getNumber() == 1)
{
toReturn += "1";
}
if (c.getNumber() == 2)
{
toReturn += "2";
}
if (c.getNumber() == 3)
{
toReturn += "3";
}
if (c.getNumber() == 4)
{
toReturn += "4";
}
if (c.getNumber() == 5)
{
toReturn += "5";
}
if (c.getNumber() == 6)
{
toReturn += "6";
}
if (c.getNumber() == 7)
{
toReturn += "7";
}
if (c.getNumber() == 8)
{
toReturn += "8";
}
if (c.getNumber() == 9)
{
toReturn += "9";
}
}
if (c.getNumber() == 10)
{
toReturn += 'S';
}
if (c.getNumber() == 11)
{
toReturn += 'D';
}
if (c.getNumber() == 12)
{
toReturn += 'R';
}
}
if (c.getColor() == BLACK)
{
if (c.getNumber() == 0)
{
toReturn += "Wild";
}
if (c.getNumber() == 1)
{
toReturn += "Dra4";
}
}
return toReturn;
}