//**************************************************************************** // File: Card.cpp // Author: Dr. Thomas C. Bressoud // Date: February 8, 2008 // Class: CS 173-01, Professor Bressoud // Purpose: Implementation file for the Card class, defining a single card // with a domain consisting of a rank and a suit. Operations include // creation and acessing rank and suit. // Input: NA // Output: NA //**************************************************************************** #include #include using namespace std; #include "Card.h" Card::Card() //============================================================================ // Purpose: Default constructor, initializing a card to the ace of spaces. // // Precondition: None // Postcondition: Created Card object with valid rank (ace) and suit (spades) //============================================================================ { mySuit = SPADES; myRank = 1; } Card::Card(int r, Suit s) //============================================================================ // Purpose: Constructor, initializing a card to the given rank r and suit s. // // Precondition: 1 <= r <= 13 && s in {SPADES, HEARTS, DIAMONDS, CLUBS} // Postcondition: Created Card object with rank r, and suit s //============================================================================ { assert(r >= 1 && r <= 13); assert((int)s >= 0 && (int)s <= NUMSUIT); mySuit = s; myRank = r; } // Below in this file, // create the function definitions for remaining function in the Card class: // // int Card::getRank() const // Card::Suit Card::getSuit() const // void Card::print() const // string Card::toString() const