-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeck.h
More file actions
44 lines (32 loc) · 1.11 KB
/
deck.h
File metadata and controls
44 lines (32 loc) · 1.11 KB
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
// 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 makes it consist of 52 cards in a random order
//
// 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.
//
// Calling shuffle again replenishes the deck with 52 cards.
#ifndef _DECK_H
#define _DECK_H
#include "card.h"
class Deck
{
static const int SIZE = 52;
//static const Card EMPTY_DECK(NULL,NULL);
public:
Deck(); // pristine, sorted deck
void shuffle(); // shuffle the deck, all 52 cards present
Card dealCard(); // get a card, after 52 are dealt, fail
void showDeck(); // for testing purposes, shows current state of deck
int size() const; // # cards left in the deck
private:
Card myCards[SIZE];
int myIndex; // current card to deal
};
#endif