Here is my rowstack.cpp
Code:
//rowstack.cpp
#include <stack>
#include <iostream>
#include "rowstack.h"
using namespace std;
void Rowstack::pushFaceDownCard(const Card& card)
{
rowstack.push_back(card); //Adds a card to the RowStack
}
Card::Card popFaceDownCard()
{
return card;
}
and here is my rowstack.h
Code:
//rowstack.h
#ifndef rowstack_h
#define rowstack_h
#include <stack>
#include <cstdlib>
#include "card.h"
class Rowstack
{
public:
void pushFaceDownCard(const Card& card); //Adds a card to the RowStack
Card popFaceDownCard(); //Returns the card at the top of the stack
bool isFaceDownEmpty() const; //Returns true if the stack containing the face down card is empty
private:
stack<Card> faceDownCards; // STL stack of Card ADT's
};
class RowstackException
{
public:
RowstackException( RowstackExceptions newException);//sets the private attribute exception to new exception
RowstackException getException() const; //returns the private attribute exception
private:
RowstackException exception;
};
#endif
Code:
and this is my Card.cpp
#include <cassert>
#include <iostream>
#include "card.h"
using namespace std;
Card::Card() :
rank( ACE ),
suit( SPADES )
{
}
Card::Card( Rank newRank, Suit newSuit ) :
rank( newRank ),
suit( newSuit )
{
}
void Card::setRank( Rank newRank )
{
rank = newRank;
}
void Card::setSuit( Suit newSuit )
{
suit = newSuit;
}
ostream& operator<<( ostream& os, const Card& card )
{
switch( card.getRank() )
{
case Card::ACE:
os << "Ace";
break;
case Card::TWO:
os << "Two";
break;
case Card::THREE:
os << "Three";
break;
case Card::FOUR:
os << "Four";
break;
case Card::FIVE:
os << "Five";
break;
case Card::SIX:
os << "Six";
break;
case Card::SEVEN:
os << "Seven";
break;
case Card::EIGHT:
os << "Eight";
break;
case Card::NINE:
os << "Nine";
break;
case Card::TEN:
os << "Ten";
break;
case Card::JACK:
os << "Jack";
break;
case Card::QUEEN:
os << "Queen";
break;
case Card::KING:
os << "King";
break;
default:
assert( 0 );
}
os << " of ";
switch( card.getSuit() )
{
case Card::SPADES:
os << "Spades";
break;
case Card::HEARTS:
os << "Hearts";
break;
case Card::CLUBS:
os << "Clubs";
break;
case Card::DIAMONDS:
os << "Diamonds";
break;
default:
assert( 0 );
}
return os;
}