-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathHand.h
51 lines (47 loc) · 915 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
40
41
42
43
44
45
46
47
48
49
50
51
// Hand.h
// Created by Robin Rowe 2019-01-10
// License MIT open source
#ifndef Hand_h
#define Hand_h
#include <vector>
#include <algorithm>
#include "Card.h"
class Deck;
class Hand
{ // Hand(const Hand&) = delete;
// void operator=(const Hand&) = delete;
std::vector<Card> cards;
unsigned count;
public:
void Clear();
void Print(bool isNewline = true) const;
unsigned Draw(Deck& deck,unsigned howMany);
bool Pickup(Card card);
Card Discard(unsigned i);
~Hand()
{}
Hand(unsigned size)
: cards(size)
, count(0)
{}
bool operator!() const
{ return !count;
}
unsigned Count() const
{ return count;
}
unsigned Size() const
{ return (unsigned) cards.size();
}
bool IsFull() const
{ return count >= cards.size();
}
bool IsInvalid(unsigned i) const
{ return i >= count;
}
void Sort()
{ std::make_heap(cards.begin(),cards.end());
std::sort_heap(cards.begin(),cards.end());
}
};
#endif