I have the following code in C++. I would like to replicate the code in MATLAB language. Below you will find the instructions for the original assignment. Please include detailed comments for the code so that I may understand all processes. Thanks in advance.C++
C++ Code:
#include #include #include #include using namespace std; string suits[4]={"Hearts", "Diamonds", "Spades", "Clubs"}; string faces[12]={"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "Jack", "Queen", "King"}; class Card { public: int face,suit; Card(int face,int suit) { this->face=face; this->suit=suit; } string toString() { string nameSuit = suits[suit]; string nameFace = faces[face]; return nameFace+" of "+nameSuit; } }; class DeckOfCards { private: vector deck; int currentLocation, location; public: DeckOfCards() { for(int i=0;i0) { Card returnCard = deck[currentLocation]; returnCard.toString(); currentLocation--; } } bool moreCards() { int size = (int) deck.size(); if(size == 0) return false; else return true; } }; int main () { DeckOfCards deck; deck.shuffle(); deck.dealCard(); };
Problems In this lab, we will use MATLAB to implement a deck of cards and answer some probability questions. 1. Card Class (25 points) Write a class to represent a single card in MATLAB. The class must keep track of the face value of the card and its suite. You are free to choose your own representation scheme for each card 2. Deck of Cards (25 points) Write a class to represent a deck of 52 cards (no jokers) in MATLAB using the Card Class of Problem 1. or the deck of cards class, you must implement the following methods Create/reset and a deck of cards. You can use an array of cards or a vector in MATLAB to store the deck of cards Shuffle a deck of cards. Draw a card without replacement after shuffling the deck of cards. This method should return a card class object, and the total number of cards should be decreased by 1. Print the current contents of the deck of cards. Print both the face value and the suite. 3. Empirical Probability (25 points) Write a method that calculates the empirical probability, i.e. the probability via experiment, of getting a combination of cards. For input, ask the user in a single line for the face and suite of cards. For example, if the user enters AH 10D KS QS JC, the user wants to know the probability of getting the Ace of Hearts, the 10 of Diamonds, the King of Spades, the Queen of Spades, and the Jack of Clubs when drawing five cards. You can calculate the empirical probability by repeating the experiment 1000 times and count the number of times the first 5 cards drawn match the cards available divided by the total, i.e. 1000. This method will entail creating a deck of cards object, drawing the required number of cards after shuffling, determining a match occurred or not, and then resetting the deck of cards for each simulation Order does not matter 4. Menu (25 points Write a menu that tests the Deck of Cards class and the Empirical Probability calculator. The menu should perform the following: Create/reset a deck of cards to 52 total cards Shuffle the deck of cards. o Draw and display the suite and face of a drawn card without replacement Print the current contents of the deck Calculate the empirical probability for drawing a given set of cards Quit