-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeck.h
45 lines (31 loc) · 1.09 KB
/
deck.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
// FILE: deck.h
// written by Owen Astrachan and Roger Priebe
// this class respresents a deck of cards
// When a Deck is constructed, it contains 52 cards
// in a "regular" order (aces, twos, threes, ... , kings)
//
// Shuffling a deck will randomize whatever cards are in the deck
// Do not shuffle if you have less than 2 cards
//
// dealCard() returns a card from the deck and decreases the
// number of cards in the deck (returned by size())
// The idea is that after shuffling, calling dealCard() 52 times
// returns each card in the deck after shuffling.
// Project Finished by Adrian Melo and David Fernandez
#ifndef _DECK_H
#define _DECK_H
#include "card.h"
class Deck
{
static const int SIZE = 52;
public:
Deck(); // pristine, sorted deck
void shuffle(); // shuffle the cards in the current deck
Card dealCard(); // get a card, after 52 are dealt, fail
int size() const; // # cards left in the deck
private:
Card myCards[SIZE];
//Index set to 51 because cards go from 0 to 51
int myIndex = 51; // current card to deal
};
#endif