Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ I already have stack.h and queue.h done but not main... stack.H #ifndef STACK_H #define STACK_H class Stack { public: class EmptyStack{}; explicit Stack(int size

c++ image text in transcribed

I already have stack.h and queue.h done but not main...

stack.H #ifndef STACK_H #define STACK_H

class Stack { public: class EmptyStack{};

explicit Stack(int size = 50);

Stack(const Stack& s);

Stack& operator=(const Stack& rhs);

~Stack();

void push(int data);

int pop();

bool isEmpty() const;

private: int* list; // stack int max; // size of stack int top; // top of stack

bool full() const;

void resize(); };

#endif

queue.h

#ifndef QUEUE_H #define QUEUE_H

class Queue { public: class EmptyQueue{};

Queue();

Queue(const Queue& aQueue);

Queue& operator=(const Queue& rhs);

~Queue();

void enqueue(int data);

int dequeue();

bool isEmpty() const;

private: struct QNode{ int d; QNode* next; };

QNode* front; QNode* tail;

void copyList(QNode* list); };

#endif

My Little Games has come up with a new card game for you to simulate. It uses a special set of cards that contain the numbers 1 to 13 and there are four copies of each card in the deck. The first person to play all the cards in their hand wins. The game is played as follows: The cards are shuffled and placed into a stack Each player is dealt 7 cards from the stack in a round-robin fashion and their cards are placed into their queue The next card in the deal stack is placed into the discard stack . For their turn, each player plays the next card in his/her queue to the discard stack. If the card the player plays is HIGHER in number than the one on the top of the discard stack, the player's turn is over. If the card the player plays is EQUAL in number to the one on the top of the discard stack, the player must then take one card from the deal stack and the player's turn is over. If the player's card is LOWER in number than the one on the discard stack, the player must take two cards from the deal stack and the player's turn is over. If the deal stack runs out of cards, "turn over the discard stack and continue the game. Note that you must keep the same card on the top of the discard stack, so you will need to hold onto that card and push it back onto the discard stack before continuing the game. The first player to run out of cards wins the game. Offer to repeat the game as many times as desired. Notes: There are only two players. . You may ask for names or simply call them by whatever names you choose. Remember to design your user interface carefully. . You must use a stack for the shuffled cards, a stack for the discard pile and a queue for each player - all of type int My Little Games has come up with a new card game for you to simulate. It uses a special set of cards that contain the numbers 1 to 13 and there are four copies of each card in the deck. The first person to play all the cards in their hand wins. The game is played as follows: The cards are shuffled and placed into a stack Each player is dealt 7 cards from the stack in a round-robin fashion and their cards are placed into their queue The next card in the deal stack is placed into the discard stack . For their turn, each player plays the next card in his/her queue to the discard stack. If the card the player plays is HIGHER in number than the one on the top of the discard stack, the player's turn is over. If the card the player plays is EQUAL in number to the one on the top of the discard stack, the player must then take one card from the deal stack and the player's turn is over. If the player's card is LOWER in number than the one on the discard stack, the player must take two cards from the deal stack and the player's turn is over. If the deal stack runs out of cards, "turn over the discard stack and continue the game. Note that you must keep the same card on the top of the discard stack, so you will need to hold onto that card and push it back onto the discard stack before continuing the game. The first player to run out of cards wins the game. Offer to repeat the game as many times as desired. Notes: There are only two players. . You may ask for names or simply call them by whatever names you choose. Remember to design your user interface carefully. . You must use a stack for the shuffled cards, a stack for the discard pile and a queue for each player - all of type int

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago