-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUNOCard.cpp
85 lines (70 loc) · 1.95 KB
/
UNOCard.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
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include "UNOCard.h"
int UNOCard::getCardNumber()
{
return UNOCard::cardNumber;
}
// Returns the color of this particular UNOCard object, represented as an int.
int UNOCard::getColorNum()
{
return UNOCard::color;
}
// Returns a string that represents the color of the UNOCard object. Also in color!
string UNOCard::getColor()
{
if (UNOCard::color == RED)
return "\033[1;31mred\033[0m";
else if (UNOCard::color == GREEN)
return "\033[1;32mgreen\033[0m";
else if (UNOCard::color == YELLOW)
return "\033[1;33myellow\033[0m";
else if (UNOCard::color == BLUE)
return "\033[1;34mblue\033[0m";
else
return "no_color";
}
// Returns a string that represents the number or function of the UNOCard object.
string UNOCard::getIdentifier()
{
switch(cardNumber)
{
case 0: return "zero";
case 1: return "one";
case 2: return "two";
case 3: return "three";
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 "reverse";
case 11: return "skip";
case 12: return "draw two";
case 13: return "wilddraw";
case 14: return "wilddraw (draw 4)";
case 15: return "emptyCard (debug only)";
break;
}
// If we have reached this point, something has gone terribly wrong!
std::cout << "DEBUG: An error has occured in the getIdentifier() statement.";
return NULL;
}
string UNOCard::toString()
{
string output = UNOCard::getColor() + " " + UNOCard::getIdentifier();
return output;
}
// These are some constructors for the UNOCard
UNOCard::UNOCard(int cardNumberGiven, int colorNumberGiven)
{
cardNumber = cardNumberGiven;
color = colorNumberGiven;
}
UNOCard::UNOCard()
{
UNOCard(4, 15);
}