Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include "Card.h"
- Card::Card(int suit, int value)
- {
- suit = suit;
- value = value;
- }
- int Card::get_suit() const
- {
- return suit;
- }
- int Card::get_value() const
- {
- return value;
- }
- int Card::compare(const Card& c) const
- {
- if(value != c.value)
- {
- if(value > c.value) return 1;
- else return -1;
- }
- else if(suit != c.suit)
- {
- if(suit > c.suit) return 1;
- else return -1;
- }
- return 0;
- }
- void Card::print_card(FILE *fp) const
- {
- const char* suitchars = "CDHS";
- const char* suitvalues = "WA23456789TJQK";
- if ((suit < 0) || (suit > 3))
- fprintf(fp, "Invalid suit: %d\n",suit);
- else if ((value < 0) || (value > 13))
- fprintf(fp, "Invalid value: %d\n",value);
- fprintf(fp, "%c %c ", suitchars[suit], suitvalues[value]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement