#include <iostream> #include <time.h> #include <iomanip> #include <Windows.h> us
ID: 3772581 • Letter: #
Question
#include <iostream>
#include <time.h>
#include <iomanip>
#include <Windows.h>
using namespace std;
void gotoxy(int h, int w)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (INVALID_HANDLE_VALUE != hConsole)
{
COORD pos = { h, w };
SetConsoleCursorPosition(hConsole, pos);
}
return;
}
void PrintHeaders();
char FindSuit(int);
int FindValue(int);
char FindFace(int);
void DealFiveCards(int[], int[]);
int main()
{
system("color 4A");
int cards[52], picked[52] = { 0 }, i, num, value, Total[5] = { 0 };
char suit, Face;
srand(time(NULL));
PrintHeaders();
for (i = 0; i < 52; i++)
{
num = rand() % 52;
while (picked[num])
num = rand() % 52;
cards[i] = num;
picked[num] = 1;
}
DealFiveCards(cards, Total);
gotoxy(0, 20);
system("pause");
return 0;
}
void PrintHeaders()
{
cout << setw(8) << "P1" << setw(8) << "P2" << setw(8) << "P3" << setw(8) << "P4" << setw(8) << "P5" << endl;
cout << setw(8) << "==" << setw(8) << "==" << setw(8) << "==" << setw(8) << "==" << setw(8) << "==" << endl;
return;
}
char FindSuit(int i)
{
int j;
j = i / 13;
switch (j)
{
case 0: return char(3); // heart
break;
case 1: return char(4); // diamond
break;
case 2: return char(5); // club
break;
case 3: return char(6); // spade
break;
default: return '?';
}
}
int FindValue(int i)
{
int value, j;
j = i % 13;
if (j < 9)
value = j + 1; // A 2 3 4 5 6 7 8 9
else if (j = 10)
value = 10; // 10, J, Q, K
else if (j = 11)
value = 11;
else if (j = 12)
value = 12;
else if (j = 13)
value = 13;
return value;
}
char FindFace(int i)
{
char FaceChar;
switch (i % 13)
{
case 0: FaceChar = 'A';
break;
case 10: FaceChar = 'J';
break;
case 11: FaceChar = 'Q';
break;
case 12: FaceChar = 'K';
break;
default: FaceChar = ' ';
}
return FaceChar;
}
void DealFiveCards(int Mycards[], int Tot[])
{
int i, value, row = 1, k = 0, card[25];
char suit, Face, cardsuit[25], cardface[25];
for (i = 0; i < 25; i++)
{
suit = FindSuit(Mycards[k]);
value = FindValue(Mycards[k]);
Face = FindFace(Mycards[k]);
cardsuit[i] = suit;
card[i] = value;
cardface[i] = Face;
if (i % 5 == 0)
row++;
gotoxy((i % 5) *8, row);
if (Face == ' ')
cout << setw(7) << value;
else
cout << setw(7) << Face;
cout << suit;
k++;
}
}
void choicewinner(int card[5],char cardsuit[5],char cardface[5])
{
int i = 0;
if (card[1] = card[2])
{
if (card[3] = card[4] && card[4] = card[5])
cout << "you got three of a kind" << endl;
else if (card[3] = card[4] || card[4] = card[5])
cout << "you got a pair" << endl;
else if ((abs(card[3] - card[4]) == 1) && (abs(card[4] - card[5]) == 1))
cout << "you got a straight" << endl;
else if ()
}
}
This is a poker programe
AMPLE DOCUMENTATION IS REQUIRED.
Create a 5 card per player poker game with at least 5 players.
You must show the cards each player received
You must analyze the content of a hand such as high card to royal flush
You must indicate the winner
7 points for this project to include the above requirements (5 points)- sound (1/2 point) - color (1/2 point) - allow user to play again (1/2 point)- chips used to bet (1/2 point). If you use chips to bet, explain the rules.
can someone compelet this for me ??
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
const string faceNames[] = //{"2", "3", "4", "5", etc, "King", "Ace"};
const string suitNames[] = { "Clubs", "Diamonds", "Hearts", "Spades"}
struct Card
{
int face; //2-13
int suit; //1-4
};
void displayCard(const Card c)
{
cout << faceNames[c.face - 2] << " of " << suitNames[c.suit - 1];
}
int main()
{
Card deck[52];
Card hands[4][5]; //4 hands, 5 cards each
//assign meaningful values to Cards in the deck
int index = 0;
for(int s = 1; s < 5; ++s) //1-4
{
for(int f = 2; f < 14; ++f) //2-13
{
deck[index].face = f;
deck[index].suit = s;
++index;
}
}
//display deck
for(int i = 0; i < 52; ++i)
{
displayCard(deck[i]);
cout << endl;
}
bool more = true;
while (more)
{
//shuffle deck
//deal hands
//sort hands
//determine description of hands
//display hands as needed
//determine whether to go again or stop
}
return 0;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.