-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuit.cpp
64 lines (57 loc) · 1.13 KB
/
suit.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
/**
* @file suit.cpp
* @author DSN
* @brief Defines functions pertaining to a card's suit
* @version 0.1
* @date 2023-08-19
*
*/
#include "suit.h"
/**
* @details
* - The string representations of the club, diamond, heart, and spade suits are
* 'C', 'D', 'H', and 'S', respectively.
* - For an invalid suit, \c ? is returned.
*/
char getName(const CardSuit suit)
{
switch (suit)
{
case club:
return 'C';
case diamond:
return 'D';
case heart:
return 'H';
case spade:
return 'S';
default:
return '?';
}
}
/**
* @details Type-cast \c suit to \c CardSuit
*
*/
CardSuit getSuit(std::size_t suit)
{
return static_cast<CardSuit>(suit);
}
/**
* @details \c suit is an enumeration; so, it's type-casted to an \c int
*/
int getValue(const CardSuit suit)
{
return static_cast<int>(suit);
}
/**
* @details \c max_suits is an enumeration; so, it's type-casted to \c std::size_t
*/
std::size_t getNumSuits()
{
return static_cast<std::size_t>(max_suits);
}
std::ostream& operator<<(std::ostream& out, const CardSuit& suit)
{
return out << getName(suit);
}