-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.c
136 lines (75 loc) · 2.97 KB
/
Card.c
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*-----------------------------------------------------------------------------+
File Name: Card.c
+------------------------------------------------------------------------------+
+------------------------------------------------------------------------------+
Programming III COP4338
Author: Daniel Gonzalez P#4926400
assignment 3: Deck of Cards
Date: 10/20/2016
program description
Input: Accept input via the command-line arguments. Validate command-line
input. Input will be the number of cards/hand and the number of
hands(players), in that order.
Output: Display of a deck of cards, cards of each hands after dealing
and a winner hand..
+-------------------------------------------------------------------------+
| I Daniel Gonzalez #4926400 hereby certify that this collective work is |
| my own and none of it is the work of any other person or entity. |
+-------------------------------------------------------------------------+
how to compile and execute:
1.Open the terminal
Go to the program folder
Run the following command "make"
2.Open the terminal
Go to the program folder
Run the following command
"gcc -Wall -w -lm Main.c Game.c Deck.c Card.c Player.c -o poker"
Program execution:
From the terminal enter “./poker [#Cards][#Players]"
both arguments are required
+-----------------------------------------------------------------------------*/
#include "Main.h"
/* Include structures, prototypes and libraries for the program */
/*-----------------------------------------------------------------------------+
* [displayCard Displays a card
* @param card Card to be displayed
*/
void displayCard(Card *card)
{
const char *FACES[] = {"A","2","3","4",
"5","6","7","8","9",
"10","J","Q","K"};
const char *TYPE[] = {SPADE, CLUB,DIAMOND, HEART};
printf("|%2s%2s | ", FACES[card->face], TYPE[card->suit]);
}
/*-----------------------------------------------------------------------------+
* [displayBottomCards displays the bottom of the cards in a line
* @param cardsPerLine amount of cards per line
*/
void displayBottomCards(int cardsPerLine){
printf("%s\n","" );
int i;
for (i = 0; i < cardsPerLine; i++){
printf("|%4s| ","" );
}
printf("%s\n","" );
for (i = 0; i < cardsPerLine; i++){
printf("%s ","+----+" );
}
printf("%s\n","" );
}
/*-----------------------------------------------------------------------------+
* [displayTopCards displays the top of the cards in a line
* @param cardsPerLine amount of cards per line
*/
void displayTopCards(int cardsPerLine){
int i;
for (i = 0; i < cardsPerLine; i++){
printf("%s ","+----+" );
}
printf("%s\n","" );
for (i = 0; i < cardsPerLine; i++){
printf("|%4s| ","" );
}
printf("%s\n","" );
}