-
Notifications
You must be signed in to change notification settings - Fork 0
/
CardPile.h
58 lines (48 loc) · 1.47 KB
/
CardPile.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef CARDPILE_H
#define CARDPILE_H
#include "Card.h"
#include <deque>
class CardPile
{
public:
/**
* @brief ~CardPile a virtual deconstructor to allow base classes deconstructors to be called.
*/
virtual ~CardPile() {}
/**
* @brief getTop gets the top card on the pile.
* @return a reference to the top card on the pile.
*/
Card& getTop();
/**
* @brief add attempts to add the specified card onto the CardPile. If check is true,
* then this function will call CardPile::accepts(const Card&) to determine whether
* the pile can accept the specified card.
* @param card the card to attempt to place.
* @param check whether or not to check if the card can be placed.
* @return true if the card was successfully placed on the pile.
* @return false if the card wasn't placed on the pile.
*/
bool add(Card card, bool check=true);
/**
* @brief isEmpty determins if this CardPile is empty or not.
* @return true if the CardPile is empty.
* @return false if the CardPile isn't empty.
*/
bool isEmpty() const;
/**
* @brief getCount returns the number of cards in this pile.
* @return the number of cards in this pile.
*/
size_t getCount() const;
/**
* @brief getCards returns all of the cards on this pile.
* @return all of the cards on this pile.
*/
std::deque<Card>& getCards();
protected:
virtual bool accepts(const Card&) = 0;
private:
std::deque<Card> m_cards;
};
#endif // CARDPILE_H