-
Notifications
You must be signed in to change notification settings - Fork 0
/
card.hh
42 lines (32 loc) · 975 Bytes
/
card.hh
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
/* Class: Card
* -----------
* Represents a single card in pairs (memory) game.
* */
#ifndef CARD_HH
#define CARD_HH
enum Visibility_type {OPEN, HIDDEN, EMPTY};
const char HIDDEN_CHAR = '#';
const char EMPTY_CHAR = '.';
class Card
{
public:
// Default constructor: creates an empty card.
Card();
// Constructor: creates a hidden card with the given character.
Card(char c);
// Obvious setter and getter methods.
void set_letter(char c);
void set_visibility(Visibility_type visibility);
char get_letter() const;
Visibility_type get_visibility() const;
// Turns a card: changes the visibility from open to hidden and vice versa.
void turn();
// Prints a card based on its current state (visibility).
void print() const;
// Removes a card from the game board: changes the visibility to empty.
void remove_from_game_board();
private:
char letter_;
Visibility_type visibility_;
};
#endif // CARD_HH