Simple Blackjack/21 game in console











up vote
1
down vote

favorite












I made a simple Blackjack/21 game in C++. It does not use any fancy graphics, just the console output. It is as simple as it can get.



#include <iostream>
#include <cstdlib>
#include <ctime>
#include <algorithm>

void printData(int pTotal, int dCard) {

std::cout << "nYour total is " << pTotal;
std::cout << "nDealer has a " << dCard << " showing.n";

}

int getCard() {

return std::rand() % 11 + 2;

}

void turn(int& pTotal, char choice, bool& stay) {

// If the user wants to hit
if (choice == 'H' || choice == 'h') {

// If the user hits 21 or above
if ((pTotal += getCard()) >= 21) {

std::cout << "Your total is " << pTotal;
stay = true;

}

return;
}

// Since the only other option can be to stay, then stay
stay = true;

}

int main() {

bool stay;
char choice = NULL;

while (true) {

std::cout << "================================";
stay = false;

// Initialize srand and get random card numbers
std::srand(std::time(0));
int dCard = getCard();
int pTotal = getCard() + getCard();
int dTotal = dCard + getCard();


// Player's turn
while (!stay) {

printData(pTotal, dCard);
std::cout << "[H]it or [S]tay?n";
std::cin >> choice;
turn(pTotal, choice, stay);

}

stay = false;
std::cout << "nnIt is now the dealer's turn!n";

// Dealer's turn
while (dTotal <= 21 && !stay) {

if (dTotal >= 17)
stay = true;
else
dTotal += getCard();

}

// Display winner
std::cout << "nnThe player has " << pTotal << ".nThe dealer has " << dTotal << ".nn";
if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) std::cout << "The player wins!n";
else std::cout << "The dealer wins!n";

}

}



  1. Is this code efficient?

  2. Is the code easy to read/understand and to follow?

  3. Are variable names appropriate?










share|improve this question




























    up vote
    1
    down vote

    favorite












    I made a simple Blackjack/21 game in C++. It does not use any fancy graphics, just the console output. It is as simple as it can get.



    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    #include <algorithm>

    void printData(int pTotal, int dCard) {

    std::cout << "nYour total is " << pTotal;
    std::cout << "nDealer has a " << dCard << " showing.n";

    }

    int getCard() {

    return std::rand() % 11 + 2;

    }

    void turn(int& pTotal, char choice, bool& stay) {

    // If the user wants to hit
    if (choice == 'H' || choice == 'h') {

    // If the user hits 21 or above
    if ((pTotal += getCard()) >= 21) {

    std::cout << "Your total is " << pTotal;
    stay = true;

    }

    return;
    }

    // Since the only other option can be to stay, then stay
    stay = true;

    }

    int main() {

    bool stay;
    char choice = NULL;

    while (true) {

    std::cout << "================================";
    stay = false;

    // Initialize srand and get random card numbers
    std::srand(std::time(0));
    int dCard = getCard();
    int pTotal = getCard() + getCard();
    int dTotal = dCard + getCard();


    // Player's turn
    while (!stay) {

    printData(pTotal, dCard);
    std::cout << "[H]it or [S]tay?n";
    std::cin >> choice;
    turn(pTotal, choice, stay);

    }

    stay = false;
    std::cout << "nnIt is now the dealer's turn!n";

    // Dealer's turn
    while (dTotal <= 21 && !stay) {

    if (dTotal >= 17)
    stay = true;
    else
    dTotal += getCard();

    }

    // Display winner
    std::cout << "nnThe player has " << pTotal << ".nThe dealer has " << dTotal << ".nn";
    if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) std::cout << "The player wins!n";
    else std::cout << "The dealer wins!n";

    }

    }



    1. Is this code efficient?

    2. Is the code easy to read/understand and to follow?

    3. Are variable names appropriate?










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I made a simple Blackjack/21 game in C++. It does not use any fancy graphics, just the console output. It is as simple as it can get.



      #include <iostream>
      #include <cstdlib>
      #include <ctime>
      #include <algorithm>

      void printData(int pTotal, int dCard) {

      std::cout << "nYour total is " << pTotal;
      std::cout << "nDealer has a " << dCard << " showing.n";

      }

      int getCard() {

      return std::rand() % 11 + 2;

      }

      void turn(int& pTotal, char choice, bool& stay) {

      // If the user wants to hit
      if (choice == 'H' || choice == 'h') {

      // If the user hits 21 or above
      if ((pTotal += getCard()) >= 21) {

      std::cout << "Your total is " << pTotal;
      stay = true;

      }

      return;
      }

      // Since the only other option can be to stay, then stay
      stay = true;

      }

      int main() {

      bool stay;
      char choice = NULL;

      while (true) {

      std::cout << "================================";
      stay = false;

      // Initialize srand and get random card numbers
      std::srand(std::time(0));
      int dCard = getCard();
      int pTotal = getCard() + getCard();
      int dTotal = dCard + getCard();


      // Player's turn
      while (!stay) {

      printData(pTotal, dCard);
      std::cout << "[H]it or [S]tay?n";
      std::cin >> choice;
      turn(pTotal, choice, stay);

      }

      stay = false;
      std::cout << "nnIt is now the dealer's turn!n";

      // Dealer's turn
      while (dTotal <= 21 && !stay) {

      if (dTotal >= 17)
      stay = true;
      else
      dTotal += getCard();

      }

      // Display winner
      std::cout << "nnThe player has " << pTotal << ".nThe dealer has " << dTotal << ".nn";
      if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) std::cout << "The player wins!n";
      else std::cout << "The dealer wins!n";

      }

      }



      1. Is this code efficient?

      2. Is the code easy to read/understand and to follow?

      3. Are variable names appropriate?










      share|improve this question















      I made a simple Blackjack/21 game in C++. It does not use any fancy graphics, just the console output. It is as simple as it can get.



      #include <iostream>
      #include <cstdlib>
      #include <ctime>
      #include <algorithm>

      void printData(int pTotal, int dCard) {

      std::cout << "nYour total is " << pTotal;
      std::cout << "nDealer has a " << dCard << " showing.n";

      }

      int getCard() {

      return std::rand() % 11 + 2;

      }

      void turn(int& pTotal, char choice, bool& stay) {

      // If the user wants to hit
      if (choice == 'H' || choice == 'h') {

      // If the user hits 21 or above
      if ((pTotal += getCard()) >= 21) {

      std::cout << "Your total is " << pTotal;
      stay = true;

      }

      return;
      }

      // Since the only other option can be to stay, then stay
      stay = true;

      }

      int main() {

      bool stay;
      char choice = NULL;

      while (true) {

      std::cout << "================================";
      stay = false;

      // Initialize srand and get random card numbers
      std::srand(std::time(0));
      int dCard = getCard();
      int pTotal = getCard() + getCard();
      int dTotal = dCard + getCard();


      // Player's turn
      while (!stay) {

      printData(pTotal, dCard);
      std::cout << "[H]it or [S]tay?n";
      std::cin >> choice;
      turn(pTotal, choice, stay);

      }

      stay = false;
      std::cout << "nnIt is now the dealer's turn!n";

      // Dealer's turn
      while (dTotal <= 21 && !stay) {

      if (dTotal >= 17)
      stay = true;
      else
      dTotal += getCard();

      }

      // Display winner
      std::cout << "nnThe player has " << pTotal << ".nThe dealer has " << dTotal << ".nn";
      if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) std::cout << "The player wins!n";
      else std::cout << "The dealer wins!n";

      }

      }



      1. Is this code efficient?

      2. Is the code easy to read/understand and to follow?

      3. Are variable names appropriate?







      c++ c++11 game playing-cards






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 14 '16 at 0:40









      Jamal

      30.2k11115226




      30.2k11115226










      asked Feb 14 '16 at 0:18









      Greg M

      21138




      21138






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          I want my money back!



          Your total is 15
          Dealer has a 4 showing.
          [H]it or [S]tay?
          s


          It is now the dealer's turn!


          The player has 15.
          The dealer has 23. <<=====

          The dealer wins! <<=====


          Your casino is cheating! Also you're not handling aces, all face cards are supposed to have a value of 10, and there are 13 ranks in a suit but your getCard function can only return 11 different values (2 to 12).



          This means that you can lose right off the bat:



          $ ./a.out 
          ================================
          Your total is 24 <<====== :-(
          Dealer has a 9 showing.
          [H]it or [S]tay?




          In turn, if the player enters h and doesn't bust, you're not setting stay - this happens to work given the code flow, but it looks odd. Set it before returning.



          If the user enters gibberish, you always interpret that as stay. That's not user-friendly.



          In main:



          bool stay;
          char choice = NULL;


          That's not a valid initializer for a char - chars are not pointers. And leaving a variable (stay) uninitialized is not a good idea. You should move stay inside the loop, only declare it when you give it its first value. (I'd also use two separate variables for the dealer and the player.)

          Remove choice from main altogether. Only turn needs it, so handle the user input in there completely. (And have turn return hit/stay so you don't need that out parameter.)



          This shouldn't be inside the loop:



          std::srand(std::time(0));


          You should initialize the RNG only once, do that at the very start of main. C++11 introduced new random generation facilities, you should look into them.



          These lines are too long:



          // Display winner
          std::cout << "nnThe player has " << pTotal << ".nThe dealer has " << dTotal << ".nn";
          if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) std::cout << "The player wins!n";
          else std::cout << "The dealer wins!n";


          Try something like:



          // Display winner
          std::cout << "nnThe player has " << pTotal
          << ".nThe dealer has " << dTotal << ".nn";

          if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) {
          std::cout << "The player wins!n";
          } else {
          std::cout << "The dealer wins!n";
          }


          And once you fix your logic so that a bust directly ends the players turn, and a dealer bust makes the player win, you can get rid of the std::abs since both scores will be at most 21.






          share|improve this answer




























            up vote
            1
            down vote













            Your deck isn't fair



            This code will happily deal a card that's already been dealt:




            int getCard() {

            return std::rand() % 11 + 2;

            }



            Real Blackjack uses a finite set of cards, usually a fixed number of standard decks shuffled together. The code here is equivalent to dealing from an infinite deck (or to replacing cards to be drawn again).



            The difference may well be important to anyone using this program to practice their card-counting technique.






            share|improve this answer





















              Your Answer





              StackExchange.ifUsing("editor", function () {
              return StackExchange.using("mathjaxEditing", function () {
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
              });
              });
              }, "mathjax-editing");

              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "196"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f119915%2fsimple-blackjack-21-game-in-console%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              4
              down vote



              accepted










              I want my money back!



              Your total is 15
              Dealer has a 4 showing.
              [H]it or [S]tay?
              s


              It is now the dealer's turn!


              The player has 15.
              The dealer has 23. <<=====

              The dealer wins! <<=====


              Your casino is cheating! Also you're not handling aces, all face cards are supposed to have a value of 10, and there are 13 ranks in a suit but your getCard function can only return 11 different values (2 to 12).



              This means that you can lose right off the bat:



              $ ./a.out 
              ================================
              Your total is 24 <<====== :-(
              Dealer has a 9 showing.
              [H]it or [S]tay?




              In turn, if the player enters h and doesn't bust, you're not setting stay - this happens to work given the code flow, but it looks odd. Set it before returning.



              If the user enters gibberish, you always interpret that as stay. That's not user-friendly.



              In main:



              bool stay;
              char choice = NULL;


              That's not a valid initializer for a char - chars are not pointers. And leaving a variable (stay) uninitialized is not a good idea. You should move stay inside the loop, only declare it when you give it its first value. (I'd also use two separate variables for the dealer and the player.)

              Remove choice from main altogether. Only turn needs it, so handle the user input in there completely. (And have turn return hit/stay so you don't need that out parameter.)



              This shouldn't be inside the loop:



              std::srand(std::time(0));


              You should initialize the RNG only once, do that at the very start of main. C++11 introduced new random generation facilities, you should look into them.



              These lines are too long:



              // Display winner
              std::cout << "nnThe player has " << pTotal << ".nThe dealer has " << dTotal << ".nn";
              if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) std::cout << "The player wins!n";
              else std::cout << "The dealer wins!n";


              Try something like:



              // Display winner
              std::cout << "nnThe player has " << pTotal
              << ".nThe dealer has " << dTotal << ".nn";

              if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) {
              std::cout << "The player wins!n";
              } else {
              std::cout << "The dealer wins!n";
              }


              And once you fix your logic so that a bust directly ends the players turn, and a dealer bust makes the player win, you can get rid of the std::abs since both scores will be at most 21.






              share|improve this answer

























                up vote
                4
                down vote



                accepted










                I want my money back!



                Your total is 15
                Dealer has a 4 showing.
                [H]it or [S]tay?
                s


                It is now the dealer's turn!


                The player has 15.
                The dealer has 23. <<=====

                The dealer wins! <<=====


                Your casino is cheating! Also you're not handling aces, all face cards are supposed to have a value of 10, and there are 13 ranks in a suit but your getCard function can only return 11 different values (2 to 12).



                This means that you can lose right off the bat:



                $ ./a.out 
                ================================
                Your total is 24 <<====== :-(
                Dealer has a 9 showing.
                [H]it or [S]tay?




                In turn, if the player enters h and doesn't bust, you're not setting stay - this happens to work given the code flow, but it looks odd. Set it before returning.



                If the user enters gibberish, you always interpret that as stay. That's not user-friendly.



                In main:



                bool stay;
                char choice = NULL;


                That's not a valid initializer for a char - chars are not pointers. And leaving a variable (stay) uninitialized is not a good idea. You should move stay inside the loop, only declare it when you give it its first value. (I'd also use two separate variables for the dealer and the player.)

                Remove choice from main altogether. Only turn needs it, so handle the user input in there completely. (And have turn return hit/stay so you don't need that out parameter.)



                This shouldn't be inside the loop:



                std::srand(std::time(0));


                You should initialize the RNG only once, do that at the very start of main. C++11 introduced new random generation facilities, you should look into them.



                These lines are too long:



                // Display winner
                std::cout << "nnThe player has " << pTotal << ".nThe dealer has " << dTotal << ".nn";
                if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) std::cout << "The player wins!n";
                else std::cout << "The dealer wins!n";


                Try something like:



                // Display winner
                std::cout << "nnThe player has " << pTotal
                << ".nThe dealer has " << dTotal << ".nn";

                if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) {
                std::cout << "The player wins!n";
                } else {
                std::cout << "The dealer wins!n";
                }


                And once you fix your logic so that a bust directly ends the players turn, and a dealer bust makes the player win, you can get rid of the std::abs since both scores will be at most 21.






                share|improve this answer























                  up vote
                  4
                  down vote



                  accepted







                  up vote
                  4
                  down vote



                  accepted






                  I want my money back!



                  Your total is 15
                  Dealer has a 4 showing.
                  [H]it or [S]tay?
                  s


                  It is now the dealer's turn!


                  The player has 15.
                  The dealer has 23. <<=====

                  The dealer wins! <<=====


                  Your casino is cheating! Also you're not handling aces, all face cards are supposed to have a value of 10, and there are 13 ranks in a suit but your getCard function can only return 11 different values (2 to 12).



                  This means that you can lose right off the bat:



                  $ ./a.out 
                  ================================
                  Your total is 24 <<====== :-(
                  Dealer has a 9 showing.
                  [H]it or [S]tay?




                  In turn, if the player enters h and doesn't bust, you're not setting stay - this happens to work given the code flow, but it looks odd. Set it before returning.



                  If the user enters gibberish, you always interpret that as stay. That's not user-friendly.



                  In main:



                  bool stay;
                  char choice = NULL;


                  That's not a valid initializer for a char - chars are not pointers. And leaving a variable (stay) uninitialized is not a good idea. You should move stay inside the loop, only declare it when you give it its first value. (I'd also use two separate variables for the dealer and the player.)

                  Remove choice from main altogether. Only turn needs it, so handle the user input in there completely. (And have turn return hit/stay so you don't need that out parameter.)



                  This shouldn't be inside the loop:



                  std::srand(std::time(0));


                  You should initialize the RNG only once, do that at the very start of main. C++11 introduced new random generation facilities, you should look into them.



                  These lines are too long:



                  // Display winner
                  std::cout << "nnThe player has " << pTotal << ".nThe dealer has " << dTotal << ".nn";
                  if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) std::cout << "The player wins!n";
                  else std::cout << "The dealer wins!n";


                  Try something like:



                  // Display winner
                  std::cout << "nnThe player has " << pTotal
                  << ".nThe dealer has " << dTotal << ".nn";

                  if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) {
                  std::cout << "The player wins!n";
                  } else {
                  std::cout << "The dealer wins!n";
                  }


                  And once you fix your logic so that a bust directly ends the players turn, and a dealer bust makes the player win, you can get rid of the std::abs since both scores will be at most 21.






                  share|improve this answer












                  I want my money back!



                  Your total is 15
                  Dealer has a 4 showing.
                  [H]it or [S]tay?
                  s


                  It is now the dealer's turn!


                  The player has 15.
                  The dealer has 23. <<=====

                  The dealer wins! <<=====


                  Your casino is cheating! Also you're not handling aces, all face cards are supposed to have a value of 10, and there are 13 ranks in a suit but your getCard function can only return 11 different values (2 to 12).



                  This means that you can lose right off the bat:



                  $ ./a.out 
                  ================================
                  Your total is 24 <<====== :-(
                  Dealer has a 9 showing.
                  [H]it or [S]tay?




                  In turn, if the player enters h and doesn't bust, you're not setting stay - this happens to work given the code flow, but it looks odd. Set it before returning.



                  If the user enters gibberish, you always interpret that as stay. That's not user-friendly.



                  In main:



                  bool stay;
                  char choice = NULL;


                  That's not a valid initializer for a char - chars are not pointers. And leaving a variable (stay) uninitialized is not a good idea. You should move stay inside the loop, only declare it when you give it its first value. (I'd also use two separate variables for the dealer and the player.)

                  Remove choice from main altogether. Only turn needs it, so handle the user input in there completely. (And have turn return hit/stay so you don't need that out parameter.)



                  This shouldn't be inside the loop:



                  std::srand(std::time(0));


                  You should initialize the RNG only once, do that at the very start of main. C++11 introduced new random generation facilities, you should look into them.



                  These lines are too long:



                  // Display winner
                  std::cout << "nnThe player has " << pTotal << ".nThe dealer has " << dTotal << ".nn";
                  if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) std::cout << "The player wins!n";
                  else std::cout << "The dealer wins!n";


                  Try something like:



                  // Display winner
                  std::cout << "nnThe player has " << pTotal
                  << ".nThe dealer has " << dTotal << ".nn";

                  if ((std::abs(21 - pTotal)) < (std::abs(21 - dTotal))) {
                  std::cout << "The player wins!n";
                  } else {
                  std::cout << "The dealer wins!n";
                  }


                  And once you fix your logic so that a bust directly ends the players turn, and a dealer bust makes the player win, you can get rid of the std::abs since both scores will be at most 21.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 14 '16 at 8:08









                  Mat

                  2,72511323




                  2,72511323
























                      up vote
                      1
                      down vote













                      Your deck isn't fair



                      This code will happily deal a card that's already been dealt:




                      int getCard() {

                      return std::rand() % 11 + 2;

                      }



                      Real Blackjack uses a finite set of cards, usually a fixed number of standard decks shuffled together. The code here is equivalent to dealing from an infinite deck (or to replacing cards to be drawn again).



                      The difference may well be important to anyone using this program to practice their card-counting technique.






                      share|improve this answer

























                        up vote
                        1
                        down vote













                        Your deck isn't fair



                        This code will happily deal a card that's already been dealt:




                        int getCard() {

                        return std::rand() % 11 + 2;

                        }



                        Real Blackjack uses a finite set of cards, usually a fixed number of standard decks shuffled together. The code here is equivalent to dealing from an infinite deck (or to replacing cards to be drawn again).



                        The difference may well be important to anyone using this program to practice their card-counting technique.






                        share|improve this answer























                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          Your deck isn't fair



                          This code will happily deal a card that's already been dealt:




                          int getCard() {

                          return std::rand() % 11 + 2;

                          }



                          Real Blackjack uses a finite set of cards, usually a fixed number of standard decks shuffled together. The code here is equivalent to dealing from an infinite deck (or to replacing cards to be drawn again).



                          The difference may well be important to anyone using this program to practice their card-counting technique.






                          share|improve this answer












                          Your deck isn't fair



                          This code will happily deal a card that's already been dealt:




                          int getCard() {

                          return std::rand() % 11 + 2;

                          }



                          Real Blackjack uses a finite set of cards, usually a fixed number of standard decks shuffled together. The code here is equivalent to dealing from an infinite deck (or to replacing cards to be drawn again).



                          The difference may well be important to anyone using this program to practice their card-counting technique.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 6 hours ago









                          Toby Speight

                          23.2k638110




                          23.2k638110






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Code Review Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              Use MathJax to format equations. MathJax reference.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f119915%2fsimple-blackjack-21-game-in-console%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Quarter-circle Tiles

                              build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                              Mont Emei