/* Card.h - Stores the suit and rank for a single playing card. 
            The default constructor makes the Ace of Spades.  */


#ifndef CARD_H
#define CARD_H


class Card  
{
public:

     enum Suit { Club, Diamond, Heart, Spade };
     enum Rank { Ace=1, Two, Trey, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King };

    		
     Card() : the_suit(Spade), the_rank(Ace)         {}		 
     Card(Suit s, Rank r) : the_suit(s), the_rank(r) {} 	        
     Card(const Card&);                                              // Copy constructor
     Card& operator=(const Card&);
    
     Suit  get_suit() const { return the_suit; }
     Rank  get_rank() const { return the_rank; }
    
     void  display_card();
     void  int_to_Suit(int i);
     void  int_to_Rank(int j);

private:

     Suit  the_suit;
     Rank  the_rank;
};


/*  Function definitions for Card class */


Card::Card(const Card& c1)
{
    the_suit = c1.the_suit;
    the_rank = c1.the_rank;
}


Card& Card::operator=(const Card& rhs)
{
    the_rank = rhs.the_rank;
    the_suit = rhs.the_suit;
    return *this;
}


/* Given an integer i, get the corresponding Suit type. This is necessary 
   because C++ does not convert from an integer to an enumerated type.  */
    
void Card::int_to_Suit(int i)
{
    switch (i)   {  
      case 0 : the_suit = Card::Club;
               break;
      case 1 : the_suit = Card::Diamond; 
               break;
      case 2 : the_suit = Card::Heart; 
               break;
      case 3 : the_suit = Card::Spade; 
               break;
      }
}  


/* Given an integer j, set the_rank to the corresponding Rank */

void Card::int_to_Rank(int j)  
{   
    switch (j)  {
      case 1  : the_rank = Card::Ace;
                break;
      case 2  : the_rank = Card::Two; 
                break;
      case 3  : the_rank = Card::Trey; 
                break;
      case 4  : the_rank = Card::Four;  
                break;
      case 5  : the_rank = Card::Five; 
                break;
      case 6  : the_rank = Card::Six; 
                break;
      case 7  : the_rank = Card::Seven; 
                break;
      case 8  : the_rank = Card::Eight; 
                break;
      case 9  : the_rank = Card::Nine; 
                break;
      case 10 : the_rank = Card::Ten; 
                break;
      case 11 : the_rank = Card::Jack; 
                break;
      case 12 : the_rank = Card::Queen; 
                break;
      case 13 : the_rank = Card::King;
                break;
      }
}


void Card::display_card()  
{
   int i = the_rank;

   switch(i)   {
      case 1  : cout << " Ace of ";
                break;
      case 11 : cout << " Jack of ";
                break;
      case 12 : cout << " Queen of ";
                break;
      case 13 : cout << " King of ";
                break;
      default : cout << " "<<i<<" of ";
                break;
   }                                             

   int j = the_suit;

   switch(j)   {
      case 0 : cout << "Clubs." << endl;
               break;
      case 1 : cout << "Diamonds." << endl;
               break;
      case 2 : cout << "Hearts." <<endl;
               break;
      case 3 : cout << "Spades." <<endl;
               break;
   }                                           
} 

#endif
