Submit a lab report (a Word document) containing the following information to th
ID: 3535928 • Letter: S
Question
Submit a lab report (a Word document) containing the following information to the Dropbox for Week 1. Include your name and the exercise number. Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output. Test Plan: Include a brief description of the method you used to confirm that your program worked properly. If necessary, include a clearly labeled table with test cases, predicted results, and actual results. Summary and Conclusions: Write a statement summarizing your predicted and actual output, and identify and explain any differences. For your conclusions, write at least one nontrivial paragraph that explains, in detail, either a significant problem you had and how you solved it or, if you had no significant problems, something you learned by doing the exercise. Answers to Lab Questions: Answer any and all of the lab questions included in the lab steps.
Summary: Write a statement summarizing your predicted and actual output; identify and explain any differences.
Conclusions: Write at least one nontrivial paragraph that explains, in detail, either a significant problem you had and how you solved it or, if you had no significant problems, something you learned by doing the exercise.
Each lab exercise should have a separate section in the lab-report document.
Your lab grade will be based upon
the formatting of your source code; the use of meaningful identifiers; the extent of internal documentation; the degree to which an exercisesà ¢Ã¢â€š ¬Ã¢â€ž ¢ specifications are met; and the completeness of your lab report.
STEP 1: Starting Visual Studio
Create a new Visual Studio empty project, and add one C++ source code file.
STEP 2: Coding
Enter the following source, which will set up the 2D array and the recommended variable declarations. It is up to the student to design and implement the remainder of the program code.
// Programmer: (put your name here)
// Course: COMP220
// Assignment: Two-Dimensional Arrays
// Description: The program will use a 2D array and a random-number
// generation to play Blackjack and keep track of a playing-card deck.
// Input: User data entry and a playing-card deck represented as a two-
// dimensional array
// Output: A screen display showing the current card hands of each player
// and the dealer, their score, win and lose status, and a final representation
// of the card deck after the game is over
#include <iostream>
#include <iomanip>
#include <windows.h>
using namespace std;
enum cardValue { TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE };
enum cardSuit { HEARTS, DIAMONDS, CLUBS, SPADES };
enum playerChar { DEALER = '0', PLAYER1 = '1', PLAYER2 = '2', PLAYER3 = '3', PLAYER4 = '4' };
const char EMPTY_CHAR = ' ';
const char HEART_CHAR = '';
const char DIAMOND_CHAR = '';
const char CLUB_CHAR = '';
const char SPADE_CHAR = '';
void main (void)
{
bool bPlayerDraw[5]; //Boolean to determine if player holds (F)
//or draws card (T)
char cPlay = 'N'; //Character variable for play game input
char cCardDeck[4][13]; //Character array representing the card deck
int iCard; //Card array index
//0 = 2 card
//1 = 3 card
//2 = 4 card
//3 = 5 card
//4 = 6 card
//5 = 7 card
//6 = 8 card
//7 = 9 card
//8 = 10 card
//9 = jack card
//10 = queen card
//11 = king card
//12 = ace card
int iNumberOfDraws = 0; //Number of rounds of card draws
int iSuit; //Suit array index
//0 = hearts
//1 = diamonds
//2 = clubs
//3 = spades
// ASCII character display reference for display card suit symbols
//3 = heart symbol
//4 = diamond symbol
//5 = club symbol
//6 = spade symbol
int iNumberOfPlayers = 0;//Number of players in current game
int iPlayerCount[5]; //Integer array to holder each player's count
//iPlayer[0] is always the dealer
int iHighestCount = 0; //Highest count for a single game
int k, m; //integer loop counters
srand(GetTickCount()); //Seed the random-number generator
//Main game loop
//Enter your code hereà ¢Ã¢â€š ¬ ¦
}
Here is a sample of the finished programà ¢Ã¢â€š ¬Ã¢â€ž ¢s output.
Welcome to Honest Sam's Blackjack Table
Glad to have you back!
Enter the number of players in the game.
There must be at least one player but no more than four.
Number of players: 3
Dealer Player 1 Player 2 Player 3
Card 1: 5à ¢Ã¢â€ž ¢ £ 7à ¢Ã¢â€ž ¢ 4à ¢Ã¢â€ž ¢ ¥ Qà ¢Ã¢â€ž ¢ ¥
Card 2: 5à ¢Ã¢â€ž ¢ Kà ¢Ã¢â€ž ¢ ¥ 5à ¢Ã¢â€ž ¢ ¥ 2à ¢Ã¢â€ž ¢
Card 3: Jà ¢Ã¢â€ž ¢ ¥ 4à ¢Ã¢â€ž ¢ 6à ¢Ã¢â€ž ¢ £ 10à ¢Ã¢â€ž ¢ ¥
Card 4: Hold Hold Qà ¢Ã¢â€ž ¢ £ Hold
Card 5: Hold Hold Hold Hold
Final: 20 21 25 22
Lose Win! Lose Lose
Display entire card deck, rows = suits, columns = card
0 = dealer card, 1 = Player 1 card, 2 = Player 2 card, etc.
Welcome to Honest Sam's Blackjack Table
Do you feel lucky today?
Do you think you should take what you have left and go home?
Press Y or y to play or any other key to exit the game.
STEP 3: Program Specifications
There must be at least one other player (you) and up to a maximum of four other players (all played by you). On a playerà ¢Ã¢â€š ¬Ã¢â€ž ¢s turn, that player may either draw a card or hold. Once a player holds, he or she should not be asked to draw another card during this game. All the cards for each player, including the first card dealt, are displayed, along with the suit symbol: spades à ¢Ã¢â€ž ¢ , clubs à ¢Ã¢â€ž ¢ £, hearts à ¢Ã¢â€ž ¢ ¥, or diamonds à ¢Ã¢â€ž ¢ ¦. Each game will start with a new, 52-card deck, which is modeled on a real deck of cards. The card deck has 52 cards with no jokers. The card deck is represented by a two-dimensional array of data-type character, where the first dimension represents the suit and the second dimension represents the card in the suit, such as the following. char CardDeck[4][13]; At the start of each game, each element of the two-dimensional array is initialized to a value of " ", or the "space" character. The deck has four suits, represented by the following dimension indices. 0 = diamonds 1 = hearts 2 = clubs 3 = spades Each suit has 13 cards: 2, 3, 4, 5, 6, 7, 8,9 ,10, jack, queen, king, and ace. Each card in a suit is represented by the following dimension indices. 0 = the 2 card 1 = the 3 card 2 = the 4 card 3 = the 5 card 4 = the 6 card 5 = the 7 card 6 = the 8 card 7 = the 9 card 8 = the 10 card 9 = the jack 10 = the queen 11 = the king 12 = the ace All the number cards are worth their face value (i.e., a 3 of diamonds is worth 3). All face cards are worth 10. An ace is worth either 1 or 11. Your final-score calculation must be able to handle this correctly for both the dealer and each player. A random-number generator must be used to select the suit and the card in the suit. Once a card and suit are selected, the program should check if the value of that array element is a "space." If the array element = "space," set the element equal to an integer, identifying the dealer or the player. 0 = dealer 1 = player 1 2 = player 2 3 = player 3 4 = player 4 If the array element ! = "space," then the random-number and card-checking process should repeat until a "card" or an array element is selected that is = "space." Once a card is drawn during a game, it cannot be drawn again. When the program first starts, it should prompt the user, asking if he or she wants to play a game of Blackjack or exit the program. If the user inputs to play the game, the next decision should be 1, 2, 3, or 4 players. At the start of the game, the dealer and each player should be dealt two cards. One of the dealerà ¢Ã¢â€š ¬Ã¢â€ž ¢s card's value and suit should not be displayed. The number of cards that the dealer will draw during a game should be determined by a random-number generator that will return a value of 0, 1, 2, or 3 cards to be drawn. Each player may then draw a card or hold. If, after drawing a card, any player or the dealer goes over a score of 21, he or she is not allowed to draw any more cards during the game. Once a player holds, he or she should not be asked to draw a card again during the game. The game continues until one of the following conditions occur: all players have declared hold; all players and the dealer have gone over 21; a maximum of five cards total are held by any player at the end of a round of card draws; or any combination of the above. The display should show each playerà ¢Ã¢â€š ¬Ã¢â€ž ¢s (and the dealerà ¢Ã¢â€š ¬Ã¢â€ž ¢s) hand and update the display after each round of card draws.
spades à ¢Ã¢â€ž ¢ , clubs à ¢Ã¢â€ž ¢ £, hearts à ¢Ã¢â€ž ¢ ¥, and diamonds à ¢Ã¢â€ž ¢ ¦
Example
Player 1:
At the end of a game, the display should be repeated, with the addition of win or lose and an updated balance.
Example