#include "newdeal.h"
#include
// CLASSINV: two <= _rank <= ace &&
// clubs <= _suit <= spades
//=======================> Default Constructor <==========================
CardType::CardType ()
// POST: A card has been created &&
// _rank = ace &&
// _suit = spades
{
_rank = ace;
_suit = spades;
}
//=======================> Constructor <==========================
CardType::CardType(CardValType rank, SuitType suit)
// POST: A card has been created &&
// _rank = rank &&
// _suit = suit
{
_rank = rank;
_suit = suit;
}
//=======================> CardSuit <==========================
SuitType CardType::suit() const
// POST: FCTVAL == _suit
{
return (_suit);
}
//=======================> CardRank <==========================
CardValType CardType::rank() const
// POST: FCTVAL == _rank
{
return (_rank);
}
//=======================> display <==========================
void CardType::display () const
// POST: This card has been sent to cout as:
// where is a single character representing
// the rank of the card ('2' - '9' , 'T' , 'J' , 'Q' , 'K' , 'A')
// and is one of: "Clubs" , "Diamonds" , "Hearts" , "Spades"
{
switch (_rank)
{
case two: cout << " 2 ";
break;
case three: cout << " 3 ";
break;
case four: cout << " 4 ";
break;
case five: cout << " 5 ";
break;
case six: cout << " 6 ";
break;
case seven: cout << " 7 ";
break;
case eight: cout << " 8 ";
break;
case nine: cout << " 9 ";
break;
case ten: cout << "10 ";
break;
case jack: cout << " J ";
break;
case queen: cout << " Q ";
break;
case king: cout << " K ";
break;
case ace: cout << " A ";
break;
}
switch (_suit)
{
case clubs: cout << "Clubs";
break;
case diamonds: cout << "Diamonds";
break;
case hearts: cout << "Hearts";
break;
case spades: cout << "Spades";
break;
}
cout << endl;
return;
}