SlideShare a Scribd company logo
1 of 7
Below is the 5 small C++ files, files names are in "Bold"
please put everything under one file "Solitaire.cpp"
please Put Card.h, Deck.h,Card.cpp,Deck.cpp under "solitaire.cpp", everything under 1 single
file
thanks
Card.h
#ifndef CARD_H
#define CARD_H
#include<iostream>
using namespace std;
class Card {
private:
char rank, suit;
public:
Card();
Card(char r, char s);
void setCard(char r, char s);
int getValue();
void showCard();
};
#endif
Card.cpp
#include "Card.h"
Card::Card() {
rank = suit = ' ';
}
Card::Card(char r, char s) {
rank = r;
suit = s;
}
void Card::setCard(char r, char s) {
rank = r;
suit = s;
}
int Card::getValue() {
if (rank == 'A') {
return 1;
}
else if (rank == '2') {
return 2;
}
else if (rank == '3') {
return 3;
}
else if (rank == '4') {
return 4;
}
else if (rank == '5') {
return 5;
}
else if (rank == '6') {
return 6;
}
else if (rank == '7') {
return 7;
}
else if (rank == '8') {
return 8;
}
else if (rank == '9') {
return 9;
}
else if (rank == 'K') {
return 10;
}
else if (rank == 'Q') {
return 10;
}
else {
return 10;
}
}
void Card::showCard() {
cout << rank << suit << ".";
}
Deck.h
#ifndef DECK_H
#define DECK_H
#include "Card.h"
class Deck {
private:
Card deck[52];
int cardsCnt;
public:
Deck();
void refreshDeck();
Card deal();
void shuffle();
int cardsLeft();
void displayDeck();
};
#endif
Deck.cpp
#include "Deck.h"
Deck::Deck() {
char ranks[] = { 'A','1','2','3','4','5','6','7','8','9','J','Q','K' };
char suits[] = { 'S','H','D','C' };
int k = 0;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++)
{
deck[k++] = Card(ranks[j], suits[i]);
}
}
cardsCnt = 52;
}
void Deck::refreshDeck() {
char ranks[] = { 'A','1','2','3','4','5','6','7','8','9','J','Q','K' };
char suits[] = { 'S','H','D','C' };
int k = 0;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++)
{
deck[k++] = Card(ranks[j], suits[i]);
}
}
cardsCnt = 52;
}
Card Deck::deal() {
Card c = deck[cardsCnt - 1];
cardsCnt--;
return c;
}
void Deck::shuffle() {
srand(0);
for (int i = 0; i < cardsCnt; i++)
{
int r = i + (rand() % (52 - i));
Card temp = deck[i];
deck[i] = deck[r];
deck[r] = temp;
}
}
int Deck::cardsLeft() {
return cardsCnt;
}
void Deck::displayDeck() {
for (int i = 0; i < 52; i++) {
if (i % 13 == 0 && i != 0) {
cout << endl;
deck[i].showCard();
cout << " ";
}
else {
deck[i].showCard();
cout << " ";
}
}
}
Solitaire.cpp
#include "Deck.h"
#include <stack>
Deck deck;
void playGame();
bool isPrime(int val);
void printStackReverse(stack<Card> s);
int main()
{
int A;
while (true) {
cout << "Welcome to Solitaire Prime!n1. A New Deckn2) Display the Deckn3) Shuffle the
Deckn4) Play the Solitaire gamen5) Exit the gamennEnter choice: ";
cin >> A;
switch (A) {
case 1:
deck.refreshDeck();
cout << "nNow New deck is createdn";
break;
case 2:
cout << "nDeck:n";
deck.displayDeck();
cout << endl;
break;
case 3:
deck.shuffle();
cout << "nShuffled deck createdn";
break;
case 4:
playGame();
break;
case 5:
cout << "nThank you for playing!!!n";
exit(0);
break;
default:
cout << "nIncorrect choice, Please try againn";
break;
}
cout << endl;
}
}
void playGame() {
cout << deck.cardsLeft() << endl;
int piles = 0, sum = 0;
stack<Card> hand;
cout << "n Playing The Solitaire game!! nn";
while (deck.cardsLeft() != 0) {
Card c = deck.deal();
sum += c.getValue();
if (isPrime(sum)) {
hand.push(c);
printStackReverse(hand);
hand = stack<Card>();
cout << " Prime: " << sum << endl;
piles++;
sum = 0;
}
else {
hand.push(c);
}
}
if (sum != 0) {
printStackReverse(hand);
hand = stack<Card>();
cout << " Losern";
}
else {
cout << "nWinner in " << piles << " piles!n";
}
}
bool isPrime(int val) {
bool prime = true;
if (val == 0 || val == 1) {
prime = false;
}
else {
for (int i = 2; i <= val / 2; ++i) {
if (val % i == 0) {
prime = false;
break;
}
}
}
if (prime)
return true;
else
return false;
}
void printStackReverse(stack<Card> s)
{
if (s.empty())
return;
Card x = s.top();
s.pop();
printStackReverse(s);
x.showCard();
cout << " ";
s.push(x);
}
Below is the 5 small C++ files- files names are in -Bold- please put e.docx

More Related Content

Similar to Below is the 5 small C++ files- files names are in -Bold- please put e.docx

project 6cards.pyimport randomclass Card( object ).docx
project 6cards.pyimport randomclass Card( object ).docxproject 6cards.pyimport randomclass Card( object ).docx
project 6cards.pyimport randomclass Card( object ).docxbriancrawford30935
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdffootstatus
 
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docxPiersRCoThomsonw
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservationSwarup Kumar Boro
 
Railway reservation
Railway reservationRailway reservation
Railway reservationSwarup Boro
 
#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdfsudhinjv
 
FaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdfFaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdfabifancystore
 
Bca 1st year C langauge .pdf
Bca 1st year C langauge .pdfBca 1st year C langauge .pdf
Bca 1st year C langauge .pdfRahul Saini
 
Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)Scott Wlaschin
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdfanujmkt
 
Introduction You implemented a Deck class in Activity 2. This cla.pdf
Introduction You implemented a Deck class in Activity 2. This cla.pdfIntroduction You implemented a Deck class in Activity 2. This cla.pdf
Introduction You implemented a Deck class in Activity 2. This cla.pdffeelinggifts
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1kkkseld
 
เกมจับคู่1
เกมจับคู่1เกมจับคู่1
เกมจับคู่1JAy YourJust'one
 

Similar to Below is the 5 small C++ files- files names are in -Bold- please put e.docx (20)

project 6cards.pyimport randomclass Card( object ).docx
project 6cards.pyimport randomclass Card( object ).docxproject 6cards.pyimport randomclass Card( object ).docx
project 6cards.pyimport randomclass Card( object ).docx
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
Railway reservation
Railway reservationRailway reservation
Railway reservation
 
Dvst
DvstDvst
Dvst
 
Code em Poker
Code em PokerCode em Poker
Code em Poker
 
AI For Texam Hold'em poker
AI For Texam Hold'em pokerAI For Texam Hold'em poker
AI For Texam Hold'em poker
 
#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf
 
FaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdfFaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdf
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
Bca 1st year C langauge .pdf
Bca 1st year C langauge .pdfBca 1st year C langauge .pdf
Bca 1st year C langauge .pdf
 
Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
 
C++ programs
C++ programsC++ programs
C++ programs
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Introduction You implemented a Deck class in Activity 2. This cla.pdf
Introduction You implemented a Deck class in Activity 2. This cla.pdfIntroduction You implemented a Deck class in Activity 2. This cla.pdf
Introduction You implemented a Deck class in Activity 2. This cla.pdf
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
เกมจับคู่1
เกมจับคู่1เกมจับคู่1
เกมจับคู่1
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 

More from RichardjOZTerryp

c- Explain several methods for how zoonotic disease-causing microbes c.docx
c- Explain several methods for how zoonotic disease-causing microbes c.docxc- Explain several methods for how zoonotic disease-causing microbes c.docx
c- Explain several methods for how zoonotic disease-causing microbes c.docxRichardjOZTerryp
 
C++ Linux Need help with lab assignment- Instructions and code is post.docx
C++ Linux Need help with lab assignment- Instructions and code is post.docxC++ Linux Need help with lab assignment- Instructions and code is post.docx
C++ Linux Need help with lab assignment- Instructions and code is post.docxRichardjOZTerryp
 
C++ 5-6-2 Basic derived class member override Define a member function.docx
C++ 5-6-2 Basic derived class member override Define a member function.docxC++ 5-6-2 Basic derived class member override Define a member function.docx
C++ 5-6-2 Basic derived class member override Define a member function.docxRichardjOZTerryp
 
By now everyone has heard news reports about balloons in the sky- Were.docx
By now everyone has heard news reports about balloons in the sky- Were.docxBy now everyone has heard news reports about balloons in the sky- Were.docx
By now everyone has heard news reports about balloons in the sky- Were.docxRichardjOZTerryp
 
Businesses that are overleveraged carry a large amount of debt and are.docx
Businesses that are overleveraged carry a large amount of debt and are.docxBusinesses that are overleveraged carry a large amount of debt and are.docx
Businesses that are overleveraged carry a large amount of debt and are.docxRichardjOZTerryp
 
Business requirements refine the Logical design phase from a functiona.docx
Business requirements refine the Logical design phase from a functiona.docxBusiness requirements refine the Logical design phase from a functiona.docx
Business requirements refine the Logical design phase from a functiona.docxRichardjOZTerryp
 
Briefly explain the following as applied to database design- What is D.docx
Briefly explain the following as applied to database design- What is D.docxBriefly explain the following as applied to database design- What is D.docx
Briefly explain the following as applied to database design- What is D.docxRichardjOZTerryp
 
bottles of wine every day- The daily production in Italy is either 200.docx
bottles of wine every day- The daily production in Italy is either 200.docxbottles of wine every day- The daily production in Italy is either 200.docx
bottles of wine every day- The daily production in Italy is either 200.docxRichardjOZTerryp
 
Bones Structure and Function Lab Identify the following structures in.docx
Bones Structure and Function Lab Identify the following structures in.docxBones Structure and Function Lab Identify the following structures in.docx
Bones Structure and Function Lab Identify the following structures in.docxRichardjOZTerryp
 
Bone and Structure Lab1-) Identify types of bones based upon their sha.docx
Bone and Structure Lab1-) Identify types of bones based upon their sha.docxBone and Structure Lab1-) Identify types of bones based upon their sha.docx
Bone and Structure Lab1-) Identify types of bones based upon their sha.docxRichardjOZTerryp
 
bond issue-What will be the total interest payments over the five-year.docx
bond issue-What will be the total interest payments over the five-year.docxbond issue-What will be the total interest payments over the five-year.docx
bond issue-What will be the total interest payments over the five-year.docxRichardjOZTerryp
 
Below is the Tycho crater on the surface of the Moon- The left image p.docx
Below is the Tycho crater on the surface of the Moon- The left image p.docxBelow is the Tycho crater on the surface of the Moon- The left image p.docx
Below is the Tycho crater on the surface of the Moon- The left image p.docxRichardjOZTerryp
 
Below b a graph showing alinear regression of Ser genotypes and dorsa.docx
Below b a graph showing alinear regression of  Ser genotypes and dorsa.docxBelow b a graph showing alinear regression of  Ser genotypes and dorsa.docx
Below b a graph showing alinear regression of Ser genotypes and dorsa.docxRichardjOZTerryp
 
Below is an impact crater on the surface of the Earth- This is the Met.docx
Below is an impact crater on the surface of the Earth- This is the Met.docxBelow is an impact crater on the surface of the Earth- This is the Met.docx
Below is an impact crater on the surface of the Earth- This is the Met.docxRichardjOZTerryp
 
Being a taker can be potentially beneficial because- Select one- A- th.docx
Being a taker can be potentially beneficial because- Select one- A- th.docxBeing a taker can be potentially beneficial because- Select one- A- th.docx
Being a taker can be potentially beneficial because- Select one- A- th.docxRichardjOZTerryp
 
below is some of the work i began on LispEvaluate on java- but i'm hav.docx
below is some of the work i began on LispEvaluate on java- but i'm hav.docxbelow is some of the work i began on LispEvaluate on java- but i'm hav.docx
below is some of the work i began on LispEvaluate on java- but i'm hav.docxRichardjOZTerryp
 
Below is an idealized diagram of several oceanic plates and a continen.docx
Below is an idealized diagram of several oceanic plates and a continen.docxBelow is an idealized diagram of several oceanic plates and a continen.docx
Below is an idealized diagram of several oceanic plates and a continen.docxRichardjOZTerryp
 
Begin on the left side of the map and trace over 30oN latitude with yo.docx
Begin on the left side of the map and trace over 30oN latitude with yo.docxBegin on the left side of the map and trace over 30oN latitude with yo.docx
Begin on the left side of the map and trace over 30oN latitude with yo.docxRichardjOZTerryp
 
Before June production is recorded- the Work in Process inventory acco.docx
Before June production is recorded- the Work in Process inventory acco.docxBefore June production is recorded- the Work in Process inventory acco.docx
Before June production is recorded- the Work in Process inventory acco.docxRichardjOZTerryp
 
Because human wants are insatiable and unlimited while available resou.docx
Because human wants are insatiable and unlimited while available resou.docxBecause human wants are insatiable and unlimited while available resou.docx
Because human wants are insatiable and unlimited while available resou.docxRichardjOZTerryp
 

More from RichardjOZTerryp (20)

c- Explain several methods for how zoonotic disease-causing microbes c.docx
c- Explain several methods for how zoonotic disease-causing microbes c.docxc- Explain several methods for how zoonotic disease-causing microbes c.docx
c- Explain several methods for how zoonotic disease-causing microbes c.docx
 
C++ Linux Need help with lab assignment- Instructions and code is post.docx
C++ Linux Need help with lab assignment- Instructions and code is post.docxC++ Linux Need help with lab assignment- Instructions and code is post.docx
C++ Linux Need help with lab assignment- Instructions and code is post.docx
 
C++ 5-6-2 Basic derived class member override Define a member function.docx
C++ 5-6-2 Basic derived class member override Define a member function.docxC++ 5-6-2 Basic derived class member override Define a member function.docx
C++ 5-6-2 Basic derived class member override Define a member function.docx
 
By now everyone has heard news reports about balloons in the sky- Were.docx
By now everyone has heard news reports about balloons in the sky- Were.docxBy now everyone has heard news reports about balloons in the sky- Were.docx
By now everyone has heard news reports about balloons in the sky- Were.docx
 
Businesses that are overleveraged carry a large amount of debt and are.docx
Businesses that are overleveraged carry a large amount of debt and are.docxBusinesses that are overleveraged carry a large amount of debt and are.docx
Businesses that are overleveraged carry a large amount of debt and are.docx
 
Business requirements refine the Logical design phase from a functiona.docx
Business requirements refine the Logical design phase from a functiona.docxBusiness requirements refine the Logical design phase from a functiona.docx
Business requirements refine the Logical design phase from a functiona.docx
 
Briefly explain the following as applied to database design- What is D.docx
Briefly explain the following as applied to database design- What is D.docxBriefly explain the following as applied to database design- What is D.docx
Briefly explain the following as applied to database design- What is D.docx
 
bottles of wine every day- The daily production in Italy is either 200.docx
bottles of wine every day- The daily production in Italy is either 200.docxbottles of wine every day- The daily production in Italy is either 200.docx
bottles of wine every day- The daily production in Italy is either 200.docx
 
Bones Structure and Function Lab Identify the following structures in.docx
Bones Structure and Function Lab Identify the following structures in.docxBones Structure and Function Lab Identify the following structures in.docx
Bones Structure and Function Lab Identify the following structures in.docx
 
Bone and Structure Lab1-) Identify types of bones based upon their sha.docx
Bone and Structure Lab1-) Identify types of bones based upon their sha.docxBone and Structure Lab1-) Identify types of bones based upon their sha.docx
Bone and Structure Lab1-) Identify types of bones based upon their sha.docx
 
bond issue-What will be the total interest payments over the five-year.docx
bond issue-What will be the total interest payments over the five-year.docxbond issue-What will be the total interest payments over the five-year.docx
bond issue-What will be the total interest payments over the five-year.docx
 
Below is the Tycho crater on the surface of the Moon- The left image p.docx
Below is the Tycho crater on the surface of the Moon- The left image p.docxBelow is the Tycho crater on the surface of the Moon- The left image p.docx
Below is the Tycho crater on the surface of the Moon- The left image p.docx
 
Below b a graph showing alinear regression of Ser genotypes and dorsa.docx
Below b a graph showing alinear regression of  Ser genotypes and dorsa.docxBelow b a graph showing alinear regression of  Ser genotypes and dorsa.docx
Below b a graph showing alinear regression of Ser genotypes and dorsa.docx
 
Below is an impact crater on the surface of the Earth- This is the Met.docx
Below is an impact crater on the surface of the Earth- This is the Met.docxBelow is an impact crater on the surface of the Earth- This is the Met.docx
Below is an impact crater on the surface of the Earth- This is the Met.docx
 
Being a taker can be potentially beneficial because- Select one- A- th.docx
Being a taker can be potentially beneficial because- Select one- A- th.docxBeing a taker can be potentially beneficial because- Select one- A- th.docx
Being a taker can be potentially beneficial because- Select one- A- th.docx
 
below is some of the work i began on LispEvaluate on java- but i'm hav.docx
below is some of the work i began on LispEvaluate on java- but i'm hav.docxbelow is some of the work i began on LispEvaluate on java- but i'm hav.docx
below is some of the work i began on LispEvaluate on java- but i'm hav.docx
 
Below is an idealized diagram of several oceanic plates and a continen.docx
Below is an idealized diagram of several oceanic plates and a continen.docxBelow is an idealized diagram of several oceanic plates and a continen.docx
Below is an idealized diagram of several oceanic plates and a continen.docx
 
Begin on the left side of the map and trace over 30oN latitude with yo.docx
Begin on the left side of the map and trace over 30oN latitude with yo.docxBegin on the left side of the map and trace over 30oN latitude with yo.docx
Begin on the left side of the map and trace over 30oN latitude with yo.docx
 
Before June production is recorded- the Work in Process inventory acco.docx
Before June production is recorded- the Work in Process inventory acco.docxBefore June production is recorded- the Work in Process inventory acco.docx
Before June production is recorded- the Work in Process inventory acco.docx
 
Because human wants are insatiable and unlimited while available resou.docx
Because human wants are insatiable and unlimited while available resou.docxBecause human wants are insatiable and unlimited while available resou.docx
Because human wants are insatiable and unlimited while available resou.docx
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Below is the 5 small C++ files- files names are in -Bold- please put e.docx

  • 1. Below is the 5 small C++ files, files names are in "Bold" please put everything under one file "Solitaire.cpp" please Put Card.h, Deck.h,Card.cpp,Deck.cpp under "solitaire.cpp", everything under 1 single file thanks Card.h #ifndef CARD_H #define CARD_H #include<iostream> using namespace std; class Card { private: char rank, suit; public: Card(); Card(char r, char s); void setCard(char r, char s); int getValue(); void showCard(); }; #endif Card.cpp #include "Card.h" Card::Card() { rank = suit = ' '; } Card::Card(char r, char s) { rank = r; suit = s; } void Card::setCard(char r, char s) { rank = r; suit = s; } int Card::getValue() { if (rank == 'A') { return 1; } else if (rank == '2') {
  • 2. return 2; } else if (rank == '3') { return 3; } else if (rank == '4') { return 4; } else if (rank == '5') { return 5; } else if (rank == '6') { return 6; } else if (rank == '7') { return 7; } else if (rank == '8') { return 8; } else if (rank == '9') { return 9; } else if (rank == 'K') { return 10; } else if (rank == 'Q') { return 10; } else { return 10; } } void Card::showCard() { cout << rank << suit << "."; } Deck.h #ifndef DECK_H #define DECK_H #include "Card.h" class Deck { private: Card deck[52]; int cardsCnt;
  • 3. public: Deck(); void refreshDeck(); Card deal(); void shuffle(); int cardsLeft(); void displayDeck(); }; #endif Deck.cpp #include "Deck.h" Deck::Deck() { char ranks[] = { 'A','1','2','3','4','5','6','7','8','9','J','Q','K' }; char suits[] = { 'S','H','D','C' }; int k = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 13; j++) { deck[k++] = Card(ranks[j], suits[i]); } } cardsCnt = 52; } void Deck::refreshDeck() { char ranks[] = { 'A','1','2','3','4','5','6','7','8','9','J','Q','K' }; char suits[] = { 'S','H','D','C' }; int k = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 13; j++) { deck[k++] = Card(ranks[j], suits[i]); } } cardsCnt = 52; } Card Deck::deal() { Card c = deck[cardsCnt - 1]; cardsCnt--; return c; } void Deck::shuffle() { srand(0); for (int i = 0; i < cardsCnt; i++) {
  • 4. int r = i + (rand() % (52 - i)); Card temp = deck[i]; deck[i] = deck[r]; deck[r] = temp; } } int Deck::cardsLeft() { return cardsCnt; } void Deck::displayDeck() { for (int i = 0; i < 52; i++) { if (i % 13 == 0 && i != 0) { cout << endl; deck[i].showCard(); cout << " "; } else { deck[i].showCard(); cout << " "; } } } Solitaire.cpp #include "Deck.h" #include <stack> Deck deck; void playGame(); bool isPrime(int val); void printStackReverse(stack<Card> s); int main() { int A; while (true) { cout << "Welcome to Solitaire Prime!n1. A New Deckn2) Display the Deckn3) Shuffle the Deckn4) Play the Solitaire gamen5) Exit the gamennEnter choice: "; cin >> A; switch (A) { case 1: deck.refreshDeck(); cout << "nNow New deck is createdn"; break;
  • 5. case 2: cout << "nDeck:n"; deck.displayDeck(); cout << endl; break; case 3: deck.shuffle(); cout << "nShuffled deck createdn"; break; case 4: playGame(); break; case 5: cout << "nThank you for playing!!!n"; exit(0); break; default: cout << "nIncorrect choice, Please try againn"; break; } cout << endl; } } void playGame() { cout << deck.cardsLeft() << endl; int piles = 0, sum = 0; stack<Card> hand; cout << "n Playing The Solitaire game!! nn"; while (deck.cardsLeft() != 0) { Card c = deck.deal(); sum += c.getValue(); if (isPrime(sum)) { hand.push(c); printStackReverse(hand); hand = stack<Card>(); cout << " Prime: " << sum << endl; piles++; sum = 0; } else { hand.push(c); } } if (sum != 0) { printStackReverse(hand); hand = stack<Card>();
  • 6. cout << " Losern"; } else { cout << "nWinner in " << piles << " piles!n"; } } bool isPrime(int val) { bool prime = true; if (val == 0 || val == 1) { prime = false; } else { for (int i = 2; i <= val / 2; ++i) { if (val % i == 0) { prime = false; break; } } } if (prime) return true; else return false; } void printStackReverse(stack<Card> s) { if (s.empty()) return; Card x = s.top(); s.pop(); printStackReverse(s); x.showCard(); cout << " "; s.push(x); }