-
Notifications
You must be signed in to change notification settings - Fork 0
/
card.cpp
71 lines (60 loc) · 1013 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
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
#include "card.hh"
#include <iostream>
Card::Card():
letter_(EMPTY_CHAR), visibility_(EMPTY)
{
}
Card::Card(const char c):
letter_(c), visibility_(HIDDEN)
{
}
void Card::set_letter(const char c)
{
letter_ = c;
}
void Card::set_visibility(const Visibility_type visibility)
{
visibility_ = visibility;
}
char Card::get_letter() const
{
return letter_;
}
Visibility_type Card::get_visibility() const
{
return visibility_;
}
void Card::turn()
{
if(visibility_ == HIDDEN)
{
visibility_ = OPEN;
}
else if(visibility_ == OPEN)
{
visibility_ = HIDDEN;
}
else // if(visibility_ == EMPTY)
{
std::cout << "Cannot turn an empty place." << std::endl;
}
}
void Card::print() const
{
switch (visibility_)
{
case OPEN:
std::cout << letter_;
break;
case HIDDEN:
std::cout << HIDDEN_CHAR;
break;
case EMPTY:
std::cout << EMPTY_CHAR;
break;
}
}
void Card::remove_from_game_board()
{
visibility_ = EMPTY;
}