summaryrefslogtreecommitdiff
path: root/c2prj1_cards/cards.h
diff options
context:
space:
mode:
authorHaidong Ji2022-04-15 15:51:30 -0500
committerHaidong Ji2022-04-15 15:51:30 -0500
commit442a49ad5a48d417345959b903ae6a6d32d55759 (patch)
treec7127bb497e5e439018b1915e0136eec2c9cb124 /c2prj1_cards/cards.h
Great C programming funHEADmaster
Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git
Diffstat (limited to 'c2prj1_cards/cards.h')
-rw-r--r--c2prj1_cards/cards.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/c2prj1_cards/cards.h b/c2prj1_cards/cards.h
new file mode 100644
index 0000000..fef0529
--- /dev/null
+++ b/c2prj1_cards/cards.h
@@ -0,0 +1,38 @@
+#ifndef CARD_H
+#define CARD_H
+#define VALUE_ACE 14
+#define VALUE_KING 13
+#define VALUE_QUEEN 12
+#define VALUE_JACK 11
+typedef enum {
+ SPADES,
+ HEARTS,
+ DIAMONDS,
+ CLUBS,
+ NUM_SUITS
+} suit_t;
+
+struct card_tag {
+ unsigned value;
+ suit_t suit;
+};
+typedef struct card_tag card_t;
+typedef enum {
+ STRAIGHT_FLUSH,
+ FOUR_OF_A_KIND,
+ FULL_HOUSE,
+ FLUSH,
+ STRAIGHT,
+ THREE_OF_A_KIND,
+ TWO_PAIR,
+ PAIR,
+ NOTHING
+} hand_ranking_t;
+card_t card_from_num(unsigned c);
+void assert_card_valid(card_t c);
+const char * ranking_to_string(hand_ranking_t r) ;
+char value_letter(card_t c);
+char suit_letter(card_t c) ;
+void print_card(card_t c);
+card_t card_from_letters(char value_let, char suit_let);
+#endif