Question: Could someone please help me fix this lab assignment? #define _CRT_SECURE_NO_WARNINGS #include #include //#include #include //#include //#include struct cards; void tally(int a); void check_for_ace(int a);
Could someone please help me fix this lab assignment?
#define _CRT_SECURE_NO_WARNINGS #include
struct cards; void tally(int a); void check_for_ace(int a); void draw_card(int a); void display_hands(); void dealer_turn(); void player_turn();
FILE *fp;
int main() {
fp = fopen("cards.txt", "r");
int *argc; char *argv; allegro_init(); install_keyboard(); install_mouse(); set_color_depth(16); //set_gfx_mode(GFX_AUTODETECT_WINDOWED, 400, 400, 0, 0); argc -= optind; argv += optind; if (argv[0]) decks = atoi(argv[0]); srand(time(NULL)); int x = 0; while (x != -1) { display_hands(); int bet = 50; int alert_val = alert3("Please place your bet", NULL, NULL, "&50", "&100", "15&0", '5', '1', '0'); bet = alert_val * 50; player_cash = player_cash - bet; display_hands(); draw_card(0); draw_card(1); draw_card(1); display_hands(); player_turn(); if (hand[1].card_tally hand[1].card_tally) || (hand[0].card_tally == hand[1].card_tally || hand[1].card_tally > 21)) { alert("Dealer wins!", NULL, NULL, "&Ok", NULL, 'o', 'k'); } else { alert("Player wins!", NULL, NULL, "&Ok", NULL, 'o', 'k'); player_cash = player_cash + (bet * 2); display_hands(); } if (player_cash
fclose(); return 0; } struct cards { int card_value[10]; char card_name[10]; char card_suit[10]; int card_tally; BITMAP *card_pic[10]; }; struct cards hand[2]; short decks = 1; short cards_used[24] = { 0 }; int player_cash = 500; void endgame() { if (player_cash (decks * 4)) && (safe_guard 59) endgame(); cards_used[z] = cards_used[z] + 1; safe_guard = 0; if ((z > 1) && (z 21) { hand[0].card_tally = 0; alert("Dealer Busts!", NULL, NULL, "&Ok", NULL, 'o', 'k'); } } void player_turn() { int action = 1; while (action != 2 && hand[1].card_tally 21) alert("Player Busts!", NULL, NULL, "&Ok", NULL, 'o', 'k'); }

Blackjack Lab This assignment will focus on the use of functions and the pa parameters. You blackjack. The rules are as follows ersY ar to construct a C program that plays a simplified game of ssing of ame consists of several hands, played until the cards run out. In each hand A g dealer and the player try to accumulate cards whose point value adds up as close to 21 as possible, but not more than 21 .First the player gets a card, then the dealer gets a card, then the player gets a second card and the dealer gets a second card. The player then has the opportunity to call for more cards. Her strategy will be to refuse cards when she gets to 16 points or more (i.e., she "hits" 15 or under) If her point value goes over 21, the hand is over and the dealer wins .If the player's point value did not go over 21, the dealer calls for more cards. He must refuse cards when he gets to 17 or more (i.e., he "hits" 16 or under). If h goes over 21 the player wins the hand. Otherwise the hand with the point value closer to 21 wins the hand. In case of a tie, the dealer wins If the player is dealt 21 on the first two cards, she has blackjack and immediately wins the hand. If the dealer has 21 on the first two cards, the hand is over and the dealer wins. Cards 2 through 10 count their face value; K, Q, J count 10 points; A counts 1 if the point value in the hand is greater than 10, otherwise A counts 11 "A sample deck of cards can be found in: cards.txt. The blackjack program should be organized as follows: e program should contain a function called playHand ) w y a hand of blackjack and then set dealerWin to true (1) if the dealer alse (0) otherwise. The main( function should repeatedly call and () and keep track of the total number of wins in the game using two ealerwin and ranOut (both semi-boolean values). playHand () IS nd playerTotal. However, playlland () should set ran out of cards. In this case the program should not variables : dealerTotal a anout to true (1) if it of and exit. int the total number of wins for both the player and the dealer Page 237
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
