(c++please,thank you!!)You'll implement is the Card class, which represents a single playing card:
class Card {
private:
int rank; // Should be in the range 0-12.
int suit; // Should be in the range 0-3.
public:
// constructors, destructor, accessors, and mutators
};
You'll need to implement the needed constructors, destructors, accessor functions, and mutator methods. To do this, think carefully about what operations (if any) you’ll need to perform on an individual card and what information you’ll need to be able to get from the card. Put the definition for this class in card.hpp and the implementation in card.cpp.
Once you have a class to represent a single card, you can implement your class to represent a whole deck of 52 cards:
class Deck {
private:
Card cards[52];
int n_cards; // Number of cards remaining in the deck.
public:
// constructors, destructor, accessors, and mutators
};
Again, in addition to the attributes outlined above, you’ll need to implement any needed constructors, destructors, accessor, and mutator methods. Again, think about what operations need to be performed on a deck of cards. For shuffling, you’ll want to use C++’s rand() function. Put the definition for this class in deck.hpp and the implementation in deck.cpp.
Now that you have classes to represent cards and a deck, you should be able to implement the class to represent a player’s hand of cards:
class Hand {
private:
Card* cards;
int n_cards; // Number of cards in the hand.
public:
// constructors, destructor, accessors, and mutators
};
When writing the methods for this class, make sure you write a method to print the hand out to std::cout. Put the definition for this class in hand.hpp and the implementation in hand.cpp.
In order to test your classes, write a small program that uses them to do the following things:
Initializes a new deck of 52 cards.
Shuffles that deck.
Deals a hand of 7 cards.
Prints the contents of that hand to the console, and put this program in deal_hand.cpp.
#######################################
Card.cpp
#######################################
#include "Card.h"
string Card::get_str() {
string ranks[] = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace" };
string suits[] = { "Clubs", "Diamonds", "Hearts", "Spades" };
return ranks[rank] + " of " + suits[suit];
}
Card::Card(int rank, int suit) {
this->rank = rank;
this->suit = suit;
}
Card::Card() {
rank = 0;
suit = 0;
}
void Card::setRank(int r) {
rank = r;
}
void Card::setSuit(int s) {
suit = s;
}
#######################################
Card.h
#######################################
#include <iostream>
using namespace std;
class Card {
public:
string get_str();
Card(int rank, int suit);
Card();
void setRank(int r);
void setSuit(int s);
private:
int rank, suit;
};
#######################################
Deck.cpp
#######################################
#include "Deck.h"
Deck::Deck() {
for (int i=0; i<4; i++) {
for (int j=0; j<13; j++) {
cards[i*13 + j] = Card(j, i);
}
}
n_cards = 52;
shuffle();
}
void Deck::shuffle() {
for(int i=0; i<n_cards; i++) {
int index = rand() % n_cards;
Card t = cards[index];
cards[index] = cards[i];
cards[i] = t;
}
}
int Deck::count() {
return n_cards;
}
Card Deck::deal_card() {
if(n_cards != 0) {
return cards[--n_cards];
}
}
#######################################
Deck.h
#######################################
#include <iostream>
#include <cstdlib>
#include "Card.h"
using namespace std;
class Deck {
public:
void shuffle();
int count();
Card deal_card();
Deck();
private:
Card cards[52];
int n_cards; // Number of cards remaining in the deck.
};
#######################################
Hand.cpp
#######################################
#include "Hand.h"
Hand::Hand(int n) {
n_cards = n;
cards = new Card[n];
}
void Hand::createHand(Deck deck) {
for(int i=0; i<n_cards; i++) {
cards[i] = deck.deal_card();
}
}
void Hand::showHand() {
for(int i=0; i<n_cards; i++) {
cout << cards[i].get_str() << endl;
}
}
#######################################
Hand.h
#######################################
#include <iostream>
#include "Deck.h"
using namespace std;
class Hand {
public:
void createHand(Deck deck);
void showHand();
Hand(int n);
private:
Card* cards;
int n_cards; // Number of cards in the hand.
};
#######################################
main.cpp
#######################################
#include <ctime>
#include "Hand.h"
int main() {
srand(time(NULL));
cout << "Card Dealer" << endl;
Deck d;
Hand myHand(7);
myHand.createHand(d);
myHand.showHand();
}

Please upvote, as i have given the exact answer as asked in
question. Still in case of any concerns in code, let me know in
comments. Thanks!
(c++please,thank you!!)You'll implement is the Card class, which represents a single playing card: class Card {...
Use inheritance and classes to represent a deck of playing cards. Create a Cardclass that stores the suit (e.g. Clubs, Diamonds, Hearts, Spades), and name (e.g. Ace, 2, 10, Jack) along with appropriate accessors, constructors, and mutators. Next, create a Deck class that stores a vector of Card objects. The default constructor should create objects that represent the standard 52 cards and store them in the vector. The Deck class should have functions to: • Print every card in the...
I've created a Card class and I'm asked to implement a class called DeckOfCards that stores 52 objects of the Card class. It says to include methods to shuffle the deck, deal a card, and report the number of cards left in the deck, and a toString to show the contents of the deck. The shuffle methods should assume a full deck. I also need to create a separate driver class that first outputs the populated deck to prove it...
Given these three classes: Card, DeckOfCards, and DeckOfCardsTest. Extend the DeckofCards class to implement a BlackJack class, which implements a BlackJack game. Please do not use any java applet on the coding. Hint: Use a test class to test above classes. Pulic class Card { private final String face; // face of card ("Ace", "Deuce", ...) private final String suit; // suit of card ("Hearts", "Diamonds", ...) // two-argument constructor initializes card's face and suit public...
CARD GAME (LINKING AND SORTING) DATA STRUCTURES TOPIC(S) Topic Primary Linked lists Sorting Searching Iterators As needed Recursion OBJECTIVES Understand linked lists and sorting concepts and the syntax specific to implementing those concepts in Java. PROJECT The final objective of this project is to create a multi-player card game, but you will create your classes in the order given, as specified. (Analogy: you must have a solid foundation before you can build a house). In order to allow creative freedom,...
Please help we write a java program for this
Write a class for a single Card from a Deck of Cards. Think about what you'll need to store in a single card to identify it from the rest. Create a second class to represent the deck. Create a test program to create a complete deck of cards. Draw a UML diagram for your two classes.
C++ Practice: Answer Whichever you can & it'll help a lot. Thank you! Question 1. Implement the constructors and member function of each of the classes (Marks 15) class Fraction{ private: int numerator; int denominator; public: Fraction(int, int); float fractionValue();//determines the value of numerator/denominator }; class Problem{ private: Fraction f[3]; public: Problem(int, int, int, int, int, int); Fraction largestFraction();//Returns the fraction having largest fraction value }; Question 2: In the following Inheritance problem #include<iostream> #include<string> using namespace std; class Animal{...
HELP NEED!! Can some modified the program Below in C++ So that it can do what the Problem below asked it today???? #include <iostream> #include <stdlib.h> #include <string> #include <time.h> /* time */ #include <sstream> // for ostringstream using namespace std; // PlayingCard class class PlayingCard{ int numRank; int numSuit; string rank; string suit; public: PlayingCard(); PlayingCard(int numRank,int numSuit); void setRankString(); void setSuitString(); void setRank(int numRank); void setSuit(int numSuit); string getRank(); string getSuit(); int getRankNum(); int getSuitNum(); string getCard(); };...
The class dateType is designed to implement the date in a program, but the member function setDate and the constructor do not check whether the date is valid before storing the date in the data members. Rewrite the definitions of the function setDate and the constructor so that the values for the month, day, and the year are checked before storing the date into the data members. Add a function member, isLeapYear, to check whether a year is a leap...
HELP NEED!! Can some modified the program Below in C++ So that it can do what the Problem below asked it today???? #include <iostream> #include <stdlib.h> #include <string> #include <time.h> /* time */ #include <sstream> // for ostringstream using namespace std; // PlayingCard class class PlayingCard{ int numRank; int numSuit; string rank; string suit; public: PlayingCard(); PlayingCard(int numRank,int numSuit); void setRankString(); void setSuitString(); void setRank(int numRank); void setSuit(int numSuit); string getRank(); string getSuit(); int getRankNum(); int getSuitNum(); string getCard(); };...
War—A Card game Playing cards are used in many computer games, including versions of such classics as solitaire, hearts, and poker. War: Deal two Cards—one for the computer and one for the player—and determine the higher card, then display a message indicating whether the cards are equal, the computer won, or the player won. (Playing cards are considered equal when they have the same value, no matter what their suit is.) For this game, assume the Ace (value 1) is...