Question: Language in C++ Problem Definition Write a Card class and a Deck class that stores a deck of these Cards. Then, use the Monte Carlo





Problem Definition 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 (each simulation), Your main function should seed the random function with the seed 2222 Be sure to first implement (AND UNIT TEST!) the Card class first. Then implement (AND UNIT TESTI!) the Deck class. Then implement the hasPair function (AND UNIT TEST!!!) before finally using all of the above to write the program to determine the odds of receiving at least one pair in a hand of cards. Given a random seed of 2222, here is what a sample run of your program will look like in Jupyterlab 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.344 Here is what a sample run of your program will look like in JupyterLab 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 of receiving a pair in a hand of 5 cards is: 400 And the file hands.dat in this case would look like this: 10 of Hearts, Ace of Spades, 6 of clubs, 8 of Spades, Jack of Hearts Found Pair!! Jack of Diamonds, 3 of Diamonds, 2 of Clubs, 2 of Diamonds, 7 of Diamonds Found Pair!! 6 of clubs, Queen of Hearts, 4 of Spades, 2 of Hearts, 6 of Hearts 7 of Spades, 8 of clubs, Queen of Hearts, 10 of Spades, 4 of 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 of Clubs, 7 of clubs, 9 of Hearts, Jack of 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 clubs 375598345344 day LAB ACTIVITY 4.14.1: PROGRAM 3: Deck/Card classes w/ file output testing 0/100 Submission Instructions Downloadable files Card.h Deck.cpp main.cpp and Deck. Download Compile command g++ Deck.cpp Card.cpp main.cpp -Wall -Werror - Wuninitialized - We will use this command to compile your code a.out Upload your files below by dragging and dropping into the area or choosing a file on your hard drive. Deck.cpp Drag file here or Choose on hard drive. Card.cpp Drag file here or Choose on hard drive. main.cpp Drag file here or Choose on hard drive Submit for grading (Global Scope) Deck.h X Card.h main.cpp* Card.cpp Deck.cpp* Miscellaneous Files 1 #ifndef DECK H 2 #define DECK_H 3 4 #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
