Question
Please someone help me with this c++ program, below are the data files. Thank you. card.cpp: /* * card.cpp * Poker * */ #include #include
Please someone help me with this c++ program, below are the data files. Thank you.
card.cpp:
/* * card.cpp * Poker * */
#include
using namespace std;
const char * Card::snames[4] = {" Diamonds", "Hearts", "Clubs", "Spades" }; const char * Card::vnames[14] = {" Bad Card", "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" };
Card::Card() { v = NullCard; }
Card::Card(Suit newSuit, Value newValue) { s = newSuit; v = newValue; }
Card::Suit Card::getSuit() { return s; }
Card::Value Card::getValue() { return v; }
void Card::printSuit() { cout
void Card::printValue() { cout
void Card::printCard() { printValue(); cout
Card::Suit nextSuit(Card::Suit s) { return(s+1 > Card::Spades) ? Card::Diamonds : (Card::Suit) (s+1); }
Card::Value nextValue(Card::Value v) { return(v+1 > Card::King) ? Card::Ace : (Card::Value) (v+1); }
card.h:
/* * card.h * Poker * */
#ifndef _CARD_H #define _CARD_H
class Card { public: // Define types for the suit and value enum Suit { Diamonds, Hearts, Clubs, Spades }; enum Value { NullCard, Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King }; private: static const char *snames[4]; static const char *vnames[14]; Suit s; Value v; public: // Constructors initialize a card Card(); Card(Suit newSuit, Value newValue); Suit getSuit(); // Returns a card's suit. Value getValue(); // Returns a card's value. void printSuit(); // Print a card's suit. void printValue(); // Print a card's value. void printCard(); // Print a card's suit and value. };
// Return the next suit or card value in succession
Card::Suit nextSuit(Card::Suit); Card::Value nextValue(Card::Value);
#endif
deck.cpp:
/* * deck.cpp * Poker * * Created by Richard Stegman 5/28/12. * Copyright 2010. All rights reserved. * */
#include
Deck::Deck() { int i; Card::Suit curSuit; Card::Value curValue; nextCard = 0; for(i = 0, curSuit = Card::Diamonds, curValue = Card::Ace; i
void Deck::shuffle(int swaps) { Card temp; for (int i = 0; i
Card Deck::getCard() { return(nextCard
void Deck::addCard(Card newCard) { if (nextCard > 0) inDeck[--nextCard] = newCard; }
int Deck::totalCards() { return DECKSIZE - nextCard; }
deck.h:
/* * deck.h * Poker * * Created by Richard Stegman on 5/28/12. * Copyright 2012. All rights reserved. * */
#ifndef _DECK_H #define _DECK_H
#include "card.h"
const int DECKSIZE = 52;
class Deck { private: Card inDeck[DECKSIZE]; // These are private data members and int nextCard; // can be used only by member functions. public: Deck(); // Initialization. Called automatically // when a Deck variable is declared. void shuffle(int); // Exchange random pairs of cards. Card getCard(); // Returns top card from the deck. void addCard(Card); // Put named card in the deck. int totalCards(); // Returns number of cards left in deck. };
#endif
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started