To execute the program, copy the executable file BlackJack.
Rules for BlackJack (also called 21)
1) This game will be played with a standard ‘straight’ deck of 52 cards. Each card has a suit (heart, diamond, club, or spade) and a rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, or King). The value of a card is 1 for an Ace; ranks 2…10 have a value equal to their rank, and the Jack, Queen, and King have a value of 10.
2) This game will be played with seven players, each against the dealer.
3) The game begins by dealing two cards to each of the players and the dealer. One of the dealer cards is not exposed.
4) Each player in turn can ask for many additional cards as s/he wishes, one at a time. If a player’s total exceeds 21, that player automatically loses to the dealer and is no longer in that game.
5) After each player has received all their cards, the dealer must take additional cards until the dealer’s total is at least 17, after which he can take no more cards.
6) If the dealer has a total > 21, all remaining players with total
7) More about Win/Lose/Tie
a. The dealer does not get a designation of W/L/T.
b. Each player is playing against the dealer and NOT against other players.
c. A player ties the dealer if the dealer is under 22 and both that player and the dealer have the same totals.
d. A player wins the dealer if:
1) The dealer is over 21 and the player is under 22.
OR
2) Both player and dealer under 22 and the player's total is higher than the dealer's total
e. A player lose to the dealer if:
1) The player is over 21.
OR
2) The player's total is less than the dealer's total and the dealer is under 22.
Your assignment is to design and implement a complete C++ program that plays the game interactively with 7 players. To observe how the program works, you can download and execute the file “BlackJack.exe”.
Hints for Lab 3
1) Think how the game is played. If you are not sure about a rule, ask me. Think of me as your customer and you are writing a program for me.
2) Break down the problem to sub problems. Here are some suggestion:
· Shuffle the deck using rand()%52; Remember to use srand(time(Null));
· Write a function to print your header.
· Write a function to deal two cards to each player. Keep one of the cards dealt to the dealer covered or only deal one card to the dealer.
· Write a function to update on the screen the total for a player. As you deal them another card, the total should be updated accordingly. Use row 15 for your totals.
· You always give a player a choice to take a card or pass. When a player passes his turn, her/his total remains for the duration of the game.
· When dealing a card, a function is called to generate the next available card.
· Gotoxy(column,row) will position your cursor at that location and what you send using the cout function will print to that location on the screen. Therefore, you need to keep track for each player what is the next row to write to. The column can be calculated using 0 to start for dealer and add 7 for each player. Therefore, after dealing the first two cards, dealer’s third card when dealt will be placed in 0,3 using gotoxy(0,3) and the first player’s third card will be placed in 7,3 using gotoxy(7,3) and so on.
· When printing a card value to the screen, right justify to line up your suit.
· A=1, J=10, Q=10, and K=10. Hint: A “%” operator will work great to know what card you picked. A switch statement may come in handy to assign values for these cards. Keep in mind that A, J, Q, K must be displayed as A, J, Q, and K.
· Use an array to hold your cards. There are four suits in a deck and 13 cards for a suit (A, 2…10, J, Q, and K). Using a “/” operator with a switch statement can pin point the suit of the selected card.
· To print a suit after detecting it, char(3), char(4), char(5) and char(6) will print heart, diamond, club, and spade respectively.
· The function Another_Card will ask if you want to receive a card for the current player. If yes, then call the appropriate function and display the selected card. Otherwise, move on to the next player.
· An additional 10% will be awarded for a program that will allow a user to play another game without restarting it. Hint a call to a system function “cls” will clear the screen for you.
· A function to finish the dealer after all players are done. This function will display the first card to the dealer and will automatically finish the dealer according to the rules.
· A function to calculate user’s status after the dealer is done. Win Lose, or Tie.