I want to insert a standard 52 card deck into a stack of arrays and then randomly output the deck of cards until the deck is empty. I need this to be implement in c++ using a class of a stacked array
please someone help me :(
//C++ program
#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<iomanip>
using namespace std;
enum Suit{
Spade,Heart ,Diamond,Club
};
template <class T>
class stack{
private:
int top;
int capacity;
T*arr;
public:
stack(int size){
capacity =
size;
arr = new
T[capacity];
top=-1;
}
bool isEmpty(){
return
top==-1;
}
bool isFull(){
return
top==capacity-1;
}
T Top(){
return
arr[top];
}
void pop(){
top--;
}
void push(T data){
arr[++top]=data;
}
};
class card{
private:
int number;
enum Suit suit;
string description;
public:
card(){}
void setNumber(int n){
number=n;
}
void setSuit(enum Suit s){
suit=s;
}
void setDescription(){
char ch ;
string
str="";
if(number>=2&&number<=9)
str+='0'+number;
else
if(number==1)str+="Ace";
else
if(number==10)str+="10";
else
if(number==11)str+="Jack";
else
if(number==12)str+="Queen";
else
if(number==13)str+="King";
if(suit==0)description="Spade "+str;
else
if(suit==1)description="Heart "+str;
else
if(suit==2)description="Diamond "+str;
else
if(suit==3)description="Club "+str;
}
int getNumber(){
return
number;
}
enum Suit getSuit(){
return
suit;
}
string getDescription(){
return
description;
}
};
int main(){
card deck[52];
stack<card> s(52);
for(int i=0;i<13;i++){
deck[i].setNumber(i+1);
deck[i+13].setNumber(i+1);
deck[i+26].setNumber(i+1);
deck[i+39].setNumber(i+1);
deck[i].setSuit(Spade);
deck[i+13].setSuit(Heart);
deck[i+26].setSuit(Diamond);
deck[i+39].setSuit(Club);
deck[i].setDescription();
deck[i+13].setDescription();
deck[i+26].setDescription();
deck[i+39].setDescription();
}
for(int i=0;i<52;i++)s.push(deck[i]);
while(!s.isEmpty()){
card temp = s.Top();
cout<<temp.getDescription()<<"\n";
s.pop();
}
return 0;
}
I want to insert a standard 52 card deck into a stack of arrays and then...
I need this to be implements in c++ using a stack of arrays with classes I want to output a deck of cards that's randomly distributed between two players meaning each player shall get 26 cards. I also want to add up each players pile of cards and the player with the highest sum wins Please help me with this task I am a newbie
please help me
A randomly selected card from a standard 52-card deck is noted. The card is then replaced the deck is shuffled, and a second card is selected and noted. What is the probability that both cards are Aces? There is a chance that two Aces are randomly selected (with replacement). Preview
A standard deck of cards contains 52 cards. One card is selected from the deck. (a) Compute the probability of randomly selecting a ten or three. (b) Compute the probability of randomly selecting a ten or three or four. (c) Compute the probability of randomly selecting a four or spade.
A standard deck of cards contains 52 cards. One card is selected from the deck. (a) Compute the probability of randomly selecting a club or spade. (b) Compute the probability of randomly selecting a club or spade or heart. (c) (a) Compute the probability of randomly selecting a two or club.
A standard deck of cards contains 52 cards. One card is selected from the deck. (a) Compute the probability of randomly selecting a ten or nine (b) Compute the probability of randomly selecting a ten or nine or eight (c) Compute the probability of randomly selecting a two or diamond
A standard deck of cards contains 52 cards. One card is selected from the deck. (a) Compute the probability of randomly selecting a seven or two. (b) Compute the probability of randomly selecting a seven or two or six. (c) Compute the probability of randomly selecting a five or spade.
A standard deck of cards contains 52 cards. One card is selected from the deck. (a) Compute the probability of randomly selecting a jack or king. (b) Compute the probability of randomly selecting a jack or king or nine. (c) Compute the probability of randomly selecting a two or spade.
A standard deck of cards contains 52 cards. One card is selected from the deck. (a) Compute the probability of randomly selecting a two or four. (b) Compute the probability of randomly selecting a two or four or ace. (c) Compute the probability of randomly selecting a three or heart.
A standard deck of cards contains 52 cards. One card is selected from the deck. (a) Compute the probability of randomly selecting an eight or three. (b) Compute the probability of randomly selecting an eight or three or nine. (c) Compute the probability of randomly selecting an eight or heart.
A standard deck of cards contains 52 cards. One card is selected from the deck. (a) Compute the probability of randomly selecting a two or seven. (b) Compute the probability of randomly selecting a two or seven or ace. (c) Compute the probability of randomly selecting a six or diamond. (Type an integer or a decimal rounded to three decimal places as needed.)