All pastes #185644 Raw Edit

Someone

public text v1 · immutable
#185644 ·published 2006-09-29 04:38 UTC
rendered paste body
/* CLASS PROTOTYPES */

class Card 
{
	public:
	/** FUNCTIONS **/

		// constructor
		Card(): suit(0), value(0), FaceDown(1) {}

		// destructor
		Card(int Suit, int Value, bool face_down=true): suit(Suit), value(Value), FaceDown(face_down) { }

		// puts the drawing of the card into an array
		void GetDrawing(char card[13][14]);

		// draws the array
		void Draw();

		// draws the array at specific coords
		void DrawAtXY(int, int);

		// flips the card
		void Flip();

	/** VARIABLES **/
		int suit;        // the suit of the card
		int value;		 // the value of the card
		bool FaceDown;   // if the card is face down
};

class Deck 
{
	public: 
	/** FUNCTIONS **/
		// constructor
		Deck(): cards(NULL), number_cards(0) { }

		// destructor
		~Deck()
		{ 
			// loop through each card
            for (int i=0; i<number_cards; i++)
                free(cards[i]); // and free it
            
            free(cards); // free the array of pointers
		}		
		

		// draw the deck		
		void Draw(int, int, int x_max = 80, bool horizontal=false, int num_cards=0);

		// add a card to the bottom of the deck, by card or by value
		int AddCardToBottom(Card *c);
		int AddCardToBottom(int, int, bool facedown=true);

		// drop a specific card from the deck
		bool DropCard(int);

		// shuffle the deck
		bool Shuffle(void);

		// move a card to another deck
		void SwapCardTo(int, Deck *deck);

		// move the top to another deck
		void SwapTopTo(Deck *deck);

		// move the top and flip it
		void SwapTopAndFlip(Deck *deck, bool FaceDown=false);

		// flip all the cards
		void FlipAll(bool);

		// move all the cards in the deck to another
		void AddAllCardsTo(Deck *deck);

		// get a specific card
		Card *Get(int);

		// get the top card
		Card *Top(void);

		// get the bottom card
		Card *Bottom(void);

		// remove top card from the deck
		bool DropTop(void);

		// how many cards are left
		int CardsLeft(void);

		
	private:
	/** VARIABLES **/
		Card **cards;       // array of pointers to cards
		int number_cards;   // number of cards in the array
};