Question

Using C++ Create a Blackjack program with the following features: Single player game against the dealer....

Using C++

Create a Blackjack program with the following features:

  1. Single player game against the dealer.
  2. Numbered cards count as the number they represent (example: 2 of any suit counts as 2) except the Aces which can count as either 1 or 11, at the discretion of the player holding the card.
  3. Face cards count as 10.
  4. Player starts with $500.
  5. Player places bet before being dealt a card in a new game.
  6. New game: Deal 2 cards to each player with one up and one down each.
  7. If both the dealer and the player have 21, the result is a "Push" (meaning a tie). The game ends and the player's bet is returned to them.
  8. If the player or the dealer has 21, the game ends. The bet is added to their pot if they win and deducted from them if they lose.
  9. If neither has 21, it is the player's turn. They will continue to be offerred cards (to "Hit") to add to their total until they either exceed 21 or they choose to not take any more cards (to "Stand"). If they exceeded 21, the game ends, the player loses and their bet is deducted from their pot.
  10. If the player did not exceed 21, it is the dealer's turn. The dealer must continue to take cards until their sum is 17 or greater. At that point, they must "Stand" (not take any more cards).
  11. Whoever is closer to 21 wins and the bet is either added to or deducted from the player's pot as appropriate.
  12. After a game ends and money is distributed, the player is offerred another game - as long as they still have money in their pot.
  13. The game should have a nice, easy to understand interface.
  14. The code should be well documented and indented according to the specification discussed in class.
  15. Your program should be divided up into the following functions (which should be completely commented):
    1. playGame - plays a complete game of Blackjack
    2. getBet - prompts for and returns a valid bet by the player
    3. initialDeal - deals the first 2 cards to the players and determines if there was a winner - returns 0=dealer, 1=player, 2=push, 3=no winner yet.
    4. playerTurn - handles the player's turn - returns true if the player is still in the game or false if they busted.
    5. dealerTurn - handles the dealer's turn - returns true if the dealer is still in the game or false if they busted.
    6. deal - deals a single card into a given hand
    7. showHand - displays the names of the cards in the given hand - handles hidden cards
    8. totalHand - returns the (best) total for the cards in the given hand - handle aces here
    9. getCardName - given a card number, it returns the associated card name
    10. getCardSuit - given a card number, returns the associated card suit
    11. getCardValue - given a card number, returns the value of the card (1 for aces)
    12. checkHands - called with both hands, determines if the winner (0=dealer, 1=player, 2=push)
    13. initializeDeck - initialize the deck of cards
    14. shuffleDeck - shuffle the deck of cards

What to do:

  1. Completely describe the user interface that you plan to implement.
  2. Examine the functions above and start creating prototypes for each. Think about what data needs to be passed in and what the function will return.
  3. Start designing each function. Pay attention to where data is defined in each function. Make sure the data is defined at the level where it needs to be maintained.
  4. Add any other functions you need, but defines those outlined above.
  5. Complete your design by confirming to yourself that your design is solid by "running" it as we have on the board in class.
  6. Create a skeleton of your program using the prototypes to create function stubs.
  7. Write code for a function and test it thoroughly before moving on to another function.
  8. Repeat until the program is complete.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>

#include<ctime>

#include<string>

using namespace std;

void setup();

void output();

int dealACard();

int getRand();

static int i = -1;

int main()

{

output();

setup();

}

void output()

{

string name;

cout << "Welcome to blackjack \nPlease enter your name: ";

cin >> name;

cout << "\n";

}

void setup()

{

int total, d1, p1, p2;

char choice;

d1 = getRand();

cout << "The dealer: " << endl;

cout << "?" << " + " << d1 << "\n" << endl;

p1 = getRand();

p2 = getRand();

total = p1 + p2;

cout << "You: " << endl;

cout << p1 << " + " << p2 << " = " << total << endl;

cout << "\n";

cout << "Do you want to hit (h) or stand (s)?: ";

cin >> choice;

}

int getRand()

{

if(i == 100) i = 0;

int rands[100];

srand((unsigned)time(0));

for(int index=0; index<100; index++)

{

rands[index] = (rand()%13)+1;

}

i++;

int n = rands[i];

return n;

}

-----------------------

Add a comment
Know the answer?
Add Answer to:
Using C++ Create a Blackjack program with the following features: Single player game against the dealer....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a simplified Blackjack game using the Deck and Card classes (download the attached files to...

    Create a simplified Blackjack game using the Deck and Card classes (download the attached files to start).  There is also a "TestCard" class that creates a Deck and runs some simple code. You may choose to use this file to help you get started with your game program. 1) Deal 2 cards to the "player" and 2 cards to the "dealer".  Print both the player's cards, print one of the dealer's cards. Print the total value of the player's hand. 2) Ask...

  • Need a blackjack code for my assignment its due in 3 hours: it has to include...

    Need a blackjack code for my assignment its due in 3 hours: it has to include classes and object C++. Create a fully functioning Blackjack game in three separate phases. A text based version with no graphics, a text based object oriented version and lastly an object oriented 2D graphical version. Credits (money) is kept track of throughout the game by placing a number next to the player name. Everything shown to the user will be in plain text. No...

  • Please write the program in python: 3. Design and implement a simulation of the game of...

    Please write the program in python: 3. Design and implement a simulation of the game of volleyball. Normal volleyball is played like racquetball, in that a team can only score points when it is serving. Games are played to 15, but must be won by at least two points. 7. Craps is a dice game played at many casinos. A player rolls a pair of normal six-sided dice. If the initial roll is 2, 3, or 12, the player loses....

  • Player Class Represents a participant in the game of blackjack. Must meet the following requirements: Stores...

    Player Class Represents a participant in the game of blackjack. Must meet the following requirements: Stores the individual cards that are dealt (i.e. cannot just store the sum of the cards, you need to track which specific cards you receive) Provided methods: decide_hit(self): decides whether hit or stand by randomly selecting one of the two options. Parameters: None Returns: True to indicate a hit, False to indicate a stand Must implement the following methods: Hi!! i just need help with...

  • You will write a two-class Java program that implements the Game of 21. This is a...

    You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...

  • programming language c++ its a project if anyone can help me it's will be appreciated thnk...

    programming language c++ its a project if anyone can help me it's will be appreciated thnk u. u have to create a code based on the information im giving u you can do it in 1 or 2 day i can wait 1:26 #WW 2.53% Example: A user starts with 1000 points. Game #1 - user chooses to risk 200 points. User wins game (beats the dealer). User now has 1200 points. Game #2 - user chooses to risk 500...

  • programming language c++ programming language c++ 1:25 #WW # 53% You may, if you wish, work...

    programming language c++ programming language c++ 1:25 #WW # 53% You may, if you wish, work in pairs; this means that a submission may have 2 names attached but those 2 people must have worked on the project. No free rides! The way to submit the program to me is as follows: put the entire program (main and any other functions) into a single compile. Compile it to be sure that you have the correct set of #include statements and...

  • How do I start this c++ code homework? Write a code in C++ for a BlackJack...

    How do I start this c++ code homework? Write a code in C++ for a BlackJack card game using the following simplified rules: Each card has a numerical value. Numbered cards are counted at their face value (two counts as 2 points, three, 3 points, and so on) An Ace count as either 1 point or 11 points (whichever suits the player best) Jack, queen and king count 10 points each The player will compete against the computer which represents...

  • You are helping a corporation create a new system for keeping track of casinos and customers....

    You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. You may complete this project individually or in a group of no more than 2 other people. Requirements do not change if you choose to complete the project individually or as part of a group. Customer-specific requirements You can create...

  • Using Java You are helping a corporation create a new system for keeping track of casinos...

    Using Java You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. Customer-specific requirements You can create new customers All new customers have a new customerID assigned to them, starting with 1 for the first, 2 for the second, 3 for the third, ect. New customers have names and monetary...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT