C Programming Absolute Beginner's Guide (3rd Edition)

(Romina) #1

suitsinHand[i] = 0;
}


for (i=0; i < 13; i++)
{
ranksinHand[i] = 0;
}


getFinalHand(cardRank, cardSuit, finalRank, finalSuit,
ranksinHand, suitsinHand);


printf("Your five final cards: \n");
for (i = 0; i < 5; i++)
{
suit = getSuit(finalSuit[i]);
rank = getRank(finalRank[i]);
printf("Card #%d: %c%c\n", i+1, rank, suit);
}


winnings = analyzeHand(ranksinHand,suitsinHand);
printf("You won %d!\n", betwinnings);
bank = bank - bet + (bet
winnings);
printf("\nYour bank is now %d.\n", bank);
printf("\nDo you want to play again? ");
scanf(" %c", &stillPlay);
} while (toupper(stillPlay) == 'Y');


return;
}
/**/


// Print a quick greeting as well as tell the users the value of
// different winning hands


void printGreeting()
{
printf("\n");
printf("\n\n\tWelcome to the Absolute Beginner's Casino\n\n");
printf("\tHome of Video Draw Poker\n\n");
printf("
\n");


printf("Here are the rules:\n");
printf("You start with 100 credits, and you make a bet from ");
printf("1 to 5 credits.\n");
printf("You are dealt 5 cards, and you then choose which ");
printf("cards to keep ");
printf("or discard.\n");
printf("You want to make the best possible hand.\n");
printf("\nHere is the table for winnings (assuming a ");
printf("bet of 1 credit):");
printf("\nPair\t\t\t\t1 credit");
printf("\nTwo pairs\t\t\t2 credits");
printf("\nThree of a kind\t\t\t3 credits");
printf("\nStraight\t\t\t4 credits");
printf("\nFlush\t\t\t\t5 credits");
printf("\nFull House\t\t\t8 credits");

Free download pdf