Created
August 3, 2010 04:03
-
-
Save gnuvince/505810 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Compare two cards and return: | |
* < 0 if a is smaller than b | |
* 0 if a is equal to b | |
* > 0 if a is greater than b | |
*/ | |
int CardCompare(const Card* a, const Card* b) { | |
if (a == NULL) | |
return 1; | |
if (b == NULL) | |
return -1; | |
return a->rank - b->rank; | |
} | |
/* | |
* Returns whether a card has valid values for its | |
* rank and suit. | |
*/ | |
int CardIsValid(const Card* c) { | |
return c != NULL && | |
(c->rank >= Deuce && c->rank <= Ace && | |
c->suit >= Club && c->suit <= Spade); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment