Given a deck of poker cards, and 4 players. Use C++ class to implement an intege
ID: 3611666 • Letter: G
Question
Given a deck of poker cards, and 4 players. Use C++ class to implement an integer Stack for storing the 52 cards, along with related pop, push, is Empty, is Full functions. To make sure the cards are well suffled, the srand() and rand() functions should be exercised to randomly choose cards, and push them into Stack one by one. The poker game stalls by dealing cards to the 4 players in a circular manner (popping cards from the top of Stack one by one). Each player should receive 5 cards. Write a C++ program to simulate this simple card dealing process, and display the result. Sample Output: [Hint] ASCII codes of heart, diamond, club and spade are 3. 4. 5. and 6. respectively.Explanation / Answer
#include #include #include enum { EMPTY = -1 };using namespace std;class stack {public:stack(){max_len=52;s = new int[max_len];top=EMPTY;;}~stack() { delete []s; }void reset() { top = EMPTY; }void push(int c) { s[++top] = c; }int pop() { return s[top--]; }int top_of()const { return s[top]; }bool empty()const { return top == EMPTY;}bool full()const { return top == max_len - 1;}private:int *s;int max_len;int top;};int main(){stack s; int i,j;int card[52],num,print;for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.