forked from jaredtao/DesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHand.h
39 lines (37 loc) · 730 Bytes
/
Hand.h
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
#pragma once
class Hand
{
public:
enum class HandFlags
{
Rock = 0,
Scissors = 1,
Paper = 2
};
Hand(HandFlags hand) : m_hand(hand) {}
void setHand(HandFlags hand)
{
m_hand = hand;
}
HandFlags getHand() const
{
return m_hand;
}
bool operator==(const Hand &other)
{
return other.m_hand == m_hand;
}
bool operator>(const Hand &other)
{
return (static_cast<int>(m_hand) + 1) % 3 == static_cast<int>(other.m_hand);
}
// template <HandFlags handFlag>
// static Hand &GetInstance()
// {
// static Hand hand(handFlag);
// return hand;
// }
protected:
private:
HandFlags m_hand;
};