Question
c++ help programing I need to help make main.cpp, Card.cpp, Deck.cpp //-------------------------card.h----------------------------------- //Card interface file #ifndef __CARD_H__ #define __CARD_H__ #include using namespace std; class Card
c++ help programing
I need to help make main.cpp, Card.cpp, Deck.cpp
//-------------------------card.h-----------------------------------
//Card interface file #ifndef __CARD_H__ #define __CARD_H__
#include
using namespace std;
class Card { private: char suit; int rank; public: /* Assigns a default value of 2 of Clubs */ Card(); /* Assigns the Card the suit and rank provided. suits: c = Clubs, d = Diamonds, h = Hearts, s = Spades If an invalid suit is provided, sets the suit to Clubs ranks: 1 - 13 (1 = Ace, 11 = Jack, 12 = Queen, 13 = King) If an invalid rank is provided, sets the rank to 2 Accepts lower or upper case characters for suit */ Card(char, int);
/* Returns the Card's suit */ chargetSuit() const; /* Returns the Card's rank as an integer */ intgetRank() const; /* Outputs a Card in the following format: Rank of Suit For example, if the rank is 3 and the suit is h: 3 of Hearts Or, if the rank is 1 and the suit is d: Ace of Diamonds Or, if the rank is 12 and the suit is c: Queen of Clubs etc. */ friendostream & operator
#endif
//-------------------------deck.h-----------------------------------
#ifndef __DECK_H__ #define __DECK_H__
#include using namespace std;
#include "Card.h"
class Deck { private: vectortheDeck; vectordealtCards; public: /* Constructs a Deck of 52 cards: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King of each suit. Cards should start off in this order with the order of suits being: Clubs, Diamonds, Hearts, Spades. */ Deck();
/* Deals (returns) the top card on the deck. Removes this card from theDeck and places it in the dealtCards. */ Card dealCard();
/* Places all cards back into theDeck and shuffles them into random order. */ voidshuffleDeck();
/* returns the size of the Deck (how many cards have not yet been dealt). */ unsigneddeckSize() const; };
#endif
Write a Card class and a Deck class that stores a deck of these Cards Then, use the Monte Carlo method to determine the odds of receiving at least one pair in a hand of cards. A pair is any two cards with the same rank. Recall we used the Monte Carlo method to determine the value of Pl in LAB 1 this quarter. Along with outputting to the terminal the percentage of times a pair is found, your program should also give the user the option to output to a file the contents of each hand and whether it found a pair in that hand. Be sure to reshuffle the deck between each deal (simulation) Your main function should seed the random function with the seed 2222 Given this seed, here is what a sample run of your program will look like in cloud9 if the user chooses NOT to output to a file Do you want to output all hands to a file? (Yes/No) No Enter number of cards per hand: 5 Enter number of deals (simulations): 10000 Chances of receiving a pair in a hand of 5 cards is: 49.34% Here is what a sample run of your program will look like in cloud9 if the user DOES choose to output to a file Do you want to output all hands to a file? (Yes/No) Yes Enter name of output file: hands.dat Enter number of cards per hand: 5 Enter number of deals (simulations) 10 Chances f receiving a pair in a hand f 5 cards is: 40% And the file hands.dat in this case would look like this 10 f Hearts, Ace of Spades, 6 of Clubs, 8 of Spades, Jack f Hearts Found Pair!! Jack of Diamonds, 3 of Diamonds, 2 of Clubs, 2 of Diamonds, 7 of Diamonds Found Pair!! 6f Clubs, Queen of Hearts, 4 of Spades, 2 of Hearts, 6of Hearts 7 of Spades, 8 of Clubs, Queen of Hearts, 10 of Spades, 4f Hearts Found Pair!! 9 of Hearts, King of Clubs, 5 of Spades, 9 of Diamonds, 6 of Diamonds 9 of Spades, 3 of Spades, 4 of Diamonds, Ace of Hearts, Queen of Diamonds 5 f Clubs, 7 of Clubs, 9 of Hearts, Jack f Clubs, 8 of Hearts Jack of Diamonds, 4 of Hearts, 6 of Hearts, Queen of Diamonds, 7 of Diamonds Jack of Spades, 7 of Spades, 10 of Diamonds, 5 of Clubs, 3 of Clubs Found Pair!! 8 of Clubs, Queen of Hearts, 5 of Hearts, Queen of Spades, 10 of ClubsStep 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