USING QT CREATOR FOR C++ PROGRAM Video Poker Simulation Acme Software, Inc, has
ID: 3848201 • Letter: U
Question
USING QT CREATOR FOR C++ PROGRAM
Video Poker Simulation
Acme Software, Inc, has been contracted to write a Video Poker Simulation game in basic C++ that follows the following rules:
Basic Setting:
The player places an initial bet between one (1) and fifty (50) coins, where each coin is worth $1.00. The player is then dealt five (5) cards and allowed to choose which cards, if any, they wish to keep. The cards that they do not wish to keep are discarded, and replacement cards are dealt so that they again have a total of five (5) cards. The computer then determines what amount they have won, if any.
Card Ranks and Suits:
Cards are ranked, from highest to lowest:
Ace
King
Queen
Jack
Ten
Nine
Eight
Seven
Six
Five
Four
Three
Two
Ace
(Ace can count as either low or high. See "Royal Flush"'s scoring, below.)
The card suits are: Hearts, Clubs, Diamonds, and Spades
Hand Ranks:
When you are dealt replacement cards for your discards, your new hand is evaluated. Based on what kind of hand you're holding, you'll receive a certain number of coins.
Hands are listed below, from best (highest scoring), to worst (no score):
Royal Flush - 400 coins
A straight flush, with the Ace high.
In other words, a Ten, Jack, Queen, King and Ace, all of the same suit.
Straight Flush - 50 coins
A straight flush.
In other words, all five cards are consecutive and are the same suit.
For example: Three of Clubs, Four of Clubs, Five of Clubs, Six of Clubs and Seven of Clubs.
Four of a Kind - 25 coins
Four cards of the same value. (Obviously, each of different suits.)
Full House - 8 coins
A three of a kind and a pair at the same time.
Flush - 5 points
All cards in your hand are the same suit.
Straight - 4 coins
All five cards are consecutive.
For example: Three of Clubs, Four of Spades, Five of Clubs, Six of Diamonds, and Seven of Hearts.
Three of a Kind - 3 coins
Three cards of the same value.
Two Pair - 2 coins
Two pairs of cards.
In other words, two cards in your hand are the same value, and two other cards in your hand are also the same value.
Pair - 1 coins
Two cards in your hand are the same value. In this version, they must be Jacks or better!
None of the Above - 0 coins
Each turn "costs" at least one coin to play, so if you get a pair, no additional coins are actually added to your total score. If you don't get anything, you actually lose the number of coins that you bet! If you bet more than one coin, then the returns above are multiplied by the number of coins entered to give the actual yield. This is just how handheld and Vegas video poker games actually work!
Project Requirements:
Your project must meet the following specifications:
Text-based display of what is in the player’s hand.
Read all cards to be discarded at once
Ask the user their name when starting. All players have a file of their name with their former scores. Files are named .game. The file contains the state of a previous game so that a player can resume a game at any point.
If the file does not exist, that means you have a new player, and you must welcome them to your casino. If the file exists, you must welcome them back and restore their "bank" with the value stored in the file.
Thus, your program must read and write to a file as well as verify that a file exists.
Provided adequate “help” for the player on how to play the game.
Score all hands correctly.
Know the player’s name and be “friendly”
Extra Credit:
(150 points) "Deuces Wild" Same as above, but with each of the "Deuces" (a two) being a "Wild Card." Your program then must calculate the highest return that each two will yield the player. This must include the possibility of 5 of a kind -- which pays out 1,000 coins!!!
(50 points) Incorporate the ability to handle multiple decks in the "Deuces Wild" program above.
(250 points) In the base program, and in the "Deuces Wild" programs above, the ability for the program to identify what the player currently has and a "suggestion" on what would be the "best" cards to delete.
(Mega Extra Credit - 750 points) Make a GUI card game with some GUI API that includes card faces and decks.
Explanation / Answer
#include<iostream.h>
#include<stdlib.h>
#include<time.h>
using namespace std;
bool royal(int suit[],int number[]);
bool straightFlush(int suit[],int number[]);
bool fourOfKind(int suit[],int number[]);
bool flush(int suit[],int number[]);
bool straight(int suit[],int number[]);
bool fullHouse(int suit[],int number[]);
bool threeOfKind(int suit[],int number[]);
bool twoPair(int suit[],int number[]);
bool isPair(int suit[],int number[]);
void displayCards(int suit[],int number[]);
int main()
{
srand(time(NULL));
min=20;
}
for(i=0;i<5;i++)
{
suit[i]=temps[i];
number[i]=tempn[i];
}
if(royal(suit,number))
{
cout<<" You just got a Royal Flush!!!"<cout<<"You've won"<<2000*bet/5<<"coins"<cash+=2000*bet/5;
}
else if(straightFlush(suit,number))
{
cout<<" You just got a Straight Flush!!!"<cout<<"You've won"<<250*bet/5<<"coins"<cash+=250*bet/5;
}
else if (fourOfKind(suit,number))
{
cout<<" You just got four of a Kind!!!"<cout<<"You've won"<<125*bet/5<<"coins"<cash+=125*bet/5;
}
else if(fullHouse(suit,number))
{
cout<<" You just got a full house!!!"<cout<<"You've won"<<40*bet/5<<"coins"<cash+=40*bet/5;
}
elseif(flush(suit,number))
{
cout<<" You just got a Royal Flush!!!"<cout<<"You've won"<<25*bet/5<<"coins"<cash+=25*bet/5;
}
else if(straight(suit,number))
{
cout<<" You just got a straight!!!"<cout<<"You've won"<<20*bet/5<<"coins"<cash+=20*bet/5;
}
else if(threeOfKind(suit,number))
{
cout<<" You just got three of a Kind!!!"<cout<<"You've won"<<15*bet/5<<"coins"<cash+=15*bet/5;
}
else if(twoPair(suit,number))
{
cout<<" You just got two pair!!!"<cout<<"You've won"<<10*bet/5<<"coins"<cash+=10*bet/5;
}
else if(isPair(suit,number))
{
cout<<" You just got a pair!!!"<cout<<"You've won"<<5*bet/5<<"coins"<cash+=5*bet/5;
}
else
{
cout<<" Sorry you dint get anything! You've lost"<bet= cash+1;
}
}
cout<<" thanks for playing! ";
}
void displayCards(int suit[],int number[])
{
cout<<"Your hand is:"<for(int i=0;i<5;i++)
{
if(number[i]==0)
cout<<"Ace";
else if(number[i]>0&&number[i]<10)
cout<else if(number[i]==10)
cout<<"jack";
else if(number[i]==11)
cout<<"queen";
else
cout<<"King"
cout<<"of";
if(suit[i]==0)
cout<<"hearts";
else if(suit[i]==1)
cout<<"spades";
else if(suit[i]==2)
cout<<"clubs";
else
cout<<"diamonds";
cout<}
}
bool royal(int suit[],int number[])
{
bool ace=false;king=false;
if(straight(suit,number)&&flush(suit,number))
for(int i=0;i<5;i++)
{
if(number[i]==0)
ace=true;
else if(number[i]==12)
king=true;
}
if(ace&&king)
return true;
else
return false;
}
bool straightFlush(int suit[],int number[])
{
if(straight(suit,number)&&flush(suit,number))
return true;
else
return false;
int card[4][13];
int suit[5];
int number[5];
int cards=0;
int bet=51;
int cash=50;
while(cash!=0&&bet>0)
}boolfourOfKind(int suit[],int number[])
{
int location;
for(int i=1;i<5;i++)
{
if(number[0]!=number[i])
location=i;
}
for(int i=0;i<5;i++)
{
if(number[0]!=number[i]&&number[location]!=number[i])
return false;
}
int num=0;
int num2=0;
for(int i=0;i<5;i++)
{
if(number[0]-number[i]==0)
num++;
else if(number[location]-number[i]==0)
num2++;
}
if(num==4||num2==4)
return true;
else
reurn false;
}
bool flush(int suit[],int number[])
{
for (int i=1;i<5;i++)
{
if(suit[i]!=suit[0])
return false;
else
return true;
}
bool straight(int suit[],int number[])
{
if(number[0]!=0)
{
for(int i=;i<4;i++)
{
if(number[i]+1!=number[i+1])
return false;
}
return true;
}
else
{
bool in= true;
for(int i=0;i<4;i++)
{
if (number[i]+1!=number[i+1])
in=false;
}
if(in)
return true;
else{
if(number[0]==0&&number[i]==9&&number[2]==10&&number[3]==11&&number[4]==12)
return true;
else
return false;
}
}
}
bool fullHouse(int suit[],int number[])
{
int location;
for(int i=1;i<5;i++)
{
if(number[0]!=number[i])
locaion=i;
}
for(int i=0;i<5;i++)
{
if(number[0]!=number[i]&&number[location]!=number[i])
return false;
}
int num=0;
int num2=0;
for(int i=1;i<5;i++)
{
if(number[0]-number[i]==0)
num++;
else if(number[location]-number[i]==0)
num2++;
}
if((number==3&&num2==2)||(num==2&&num2==3))
return true;
else
return false;
}
boolfourOfKind(int suit[],int number[])
{
int location,location2;
for(int i=1;i<5;i++)
{
if(number[0]!=number[i])
location=i;
}
for(int i=1;i<5;i++)
{
if(number[0]!=number[i]&&number[location]!=number[i])
location2=i;
{
for(int i=0;i<4;i++)
{
for(int z=0;z<13;z++)
{
card[i][z]=1;
}
}
while(bet>cash||bet==0)
{
cout<<"you have"<cout<<"(you can also enter any)"
}
int num=0;
int num2=0;
int num3=0;
for(int i=0;i<5;i++)
{
if(number[0]-number[i]==0)
num++;
else if(number[location]-number[i]==0)
num2++;
else if(number[location2]-number[i]==0)
num3++;
}
if(num==3||num2==3||num3==3)
return true;
else
return false;
}
bool twoPair(int suit[],int number[])
{
{
int location,location2;
for(int i=1;i<5;i++)
{
if(number[0]!=number[i])
location=i;
}
for(int i=1;i<5;i++)
{
if(number[0]!=number[i]&&number[location]!=number[i])
location2=i;
{
for(int i=1;i<5;i++)
{
if(number[0]!=number[i]&&number[location]!=number[i])&&number[location2]!=number[i])
location3=i;
}int num=0;
int num2=0;
int num3=0;
int num4=0;
for(int i=0;i<5;i++)
{
if(number[0]-number[i]==0)
num++;
else if(number[location]-number[i]==0)
num2++;
else if(number[location2]-number[i]==0)
num3++;
else if(number[location3]-number[i]==0)
num4++;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.