-
Notifications
You must be signed in to change notification settings - Fork 3
/
cardList.h
executable file
·98 lines (82 loc) · 2.94 KB
/
cardList.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* l29cardList.h
* =============================================================
* Name: Your Name
* Section: Your Section
* Project: FILL IN
* Purpose: FILL IN
* ============================================================= */
#ifndef CARDLIST_H
#define CARDLIST_H
#include "card.h"
/* a struct used to create a cardList (a list of Card structs)
* FIELD: count - the number of cards in the list
* FIELD: topCard - a pointer to the top card in the list
* FIELD: bottomCard - a pointer to the bottom card in the list
*/
typedef struct {
int count;
Card* topCard;
Card* bottomCard;
} CardList;
/* createCardList - initializes a CardList struct
* sets count, topCard, and bottomCard to valid values
* @return ptr to the newly created cardList
*/
CardList* createCardList();
/* freeCardList - deallocates the list and the CardList struct
* @param cardList - the cardList to be deallocated
*/
void freeCardList(CardList* cardList);
/* displayCardList - display the list of cards, including count and all cards
* @param cardList - the card list to display
*/
void displayCardList(CardList* cardList);
/* isEmpty - returns 1 (TRUE) if the list is empty; 0 otherwise
* @param cardList - the list to check
*/
int isEmpty(CardList* cardList);
/* listLength - returns number of cards on the list
* @param cardList - the list to check
* @return the length of the cardList
*/
int listLength(CardList* cardList);
/* makeDeck - populates a cardList with a standard set of 52-cards
* @param deck - the cardList to populate
* @pre createList() has been called on deck
*/
void makeDeck(CardList* deck);
/* shuffleCardList - randomizes the order of cards in a list
* @param cardList - the cardList to shuffle
*/
void shuffleCardList(CardList* cardList);
/* appendCard - add a card to the end of the cardList
* @param cardList - the list to add the card to
* @param card - a Card to add to the list
*/
void appendCard(CardList* cardList, Card* card);
/* prependCard - add a card to the beginning of the cardList
* @param cardList - the list to add the card to
* @param card - a Card to add to the list
*/
void prependCard(CardList* cardList, Card* card);
/* lookAtBottomCard - returns a pointer to the bottom card
* @param cardList - the cardList to look at (the list is unchanged)
* @return - card at the bottom of the list
*/
Card* lookAtBottomCard(CardList* cardList);
/* getTopCard - removes the top card from a list of cards
* @param cardList - the list to remove a card from
* @return - former top card (returns NULL for empty list)
*/
Card* getTopCard(CardList* cardList);
/* lookAtTopCard - return a pointer to the top card in a list
* @return - pointer to top card in the list
*/
Card* lookAtTopCard(CardList* cardList);
/* @brief concatenate two lists
* @param list1 - the list that grows
* @param list2 - the list that becomes part of list1 this list
* is emptied after the append
*/
void appendCardList(CardList* list1, CardList* list2);
#endif