Making betting system using data-base money on a dice role guessing game

I’m trying to create a 2-page game where you bet a set amount of cash on a dice you roll vs the computer, the highest number wins. The player also gets a luck stat that gets added to the number they roll.

There is a 3rd page with character info of how much gold and luck you start off with.

If you run out of gold in should lock you out of playing.

I have set the CSS and all the database values but I am very weak when it comes to PHP so it’s hard for me to figure this out.

I have tried to make a normal dice game before adding database side objects but because I do not possess a server at home it’s hard for me to even test if this works, I’ve searched online as well with no luck provided.

Bet.php

  <main>     <form action="roll.php" method="post">       <p>         You currently have <?php echo $  user_row['gold'];?> gold.<br>         If you do not have any gold, please do not try and play the game.<br>         Remember that luck plays an important part in this game, your maximum luck gets added to the number you role, you currently have <?php echo $  user_row['luck'];?> luck.       </p>        <!-- Input field to place the bet. Minimum is 1, maximum is the amount of gold the character has (must be pulled from database). -->        <script>        function updateTextInput(val) {          document.getElementById('textInput').value=val;        }        </script>       <input type="range" name="bet" min="1" max="<?php $  user_row['gold'];?>" onchange="updateTextInput(this.value);">       <input type="text" id="textInput" value="">       <button id="submit" type="submit" type="button" name="roll">Roll!</button><br>       <!-- If the user has no gold, replace the form (or disable it) with an error stating the user cannot play. -->       <?php         if $  user_row['gold'] >= 1         } else {           $  error = "You have run out of gold, please leave the game room. <a href='index.php'>EXIT</a>";         }       ?>     </form>   </main> ```php  Roll.php ```php   <main>         <!-- The generation of two random numbers from 1 to 20. The first is for the character and the second is for the server.         The character's luck is added to their roll.         The higher number wins, the character's gold increases or decreases appropriately and is saved to the database.         There should be some indication of which is the winning number (i.e. change in colour or pointer).         In the event of a tie, there is no change in the characters gold. -->         <?php         if(isset($  _POST['roll']))         {         $  dice = $  _POST['dice'];         $  rand = rand(1,20);         if($  dice == $  rand)         {             echo "<br>" . "Congratulations you have rolled the number " . $  rand . "which is higher than my own roll, you have earned yourself bonus gold!";         }              echo "<br>" . "Oh, bummer traveler, it seems that you rolled " . $  dice . "which is a lower number than " . $  rand . ", I have taken the liberty of taking out some of your gold. Better luck next time!";         }         ?>       </figcaption>     </figure>     <div class=dice>       <img src="d20.png">     </div>     <p>You now have <?php echo $  user_row['gold']; ?> gold.</p>     <!-- A link back to index.php so the user can play again. -->     <!-- If the character has no gold left, display an error stating the user cannot play. -->     <a href='bet.php'>Play again?</a>     <?php       if $  user_row['gold'] >= 1         echo "You still have some gold left, why not try and earn yourself some more extra pocket change.";       } else {         $  error = "You have run out of gold, please leave the game room. <a href='index.php'>EXIT</a>";       }     ?>   </main> ```php  On the bet.php page a have this code, I don't know how to make the max bet the amount of gold currently in the database, and if the user has less than 1 gold they get kicked out/locked out of playing the game.  This is roll.php here is where I'm having trouble creating the dice roll itself, and I don't know how to add luck to the number that the player would roll.  Even the code I've already tried to put in is probably wrong, as mentioned I'm very weak when it comes to PHP, any help at all is greatly appreciated. 

A betting game using a dice class in C#

This is my first project over 100 lines and I would like some feedback on it. If anyone has any ideas for things to add or ways to make the code more efficient they would be very much appreciated.

class Program {     static void Main(string[] args)     {         Betting game1 = new Betting();         game1.rules();         Console.WriteLine("");         while (true)         {             game1.game();             string answer = "";             Console.WriteLine("");             while (true)             {                 Console.Write("Would you like to play again?(y or n) ");                 answer = Console.ReadLine();                 if (!answer.ToLower().Equals("y") && !answer.ToLower().Equals("n"))                 {                     Console.WriteLine("Please enter a valid answer.");                     Console.WriteLine("");                     continue;                 }                 else                     break;             }             if (answer.ToLower().Equals("y")) {                 game1.playAgain(answer);                 continue;             }             else                 break;         }     } }  class Betting {     private static long cashAmount;     private static long player1Amount;     private static long player2Amount;     private static int rollAmount;     private static long betAmountPlayer1;     private static long betAmountPlayer2;     private int numGames;       public Betting()     {         cashAmount = 1500;         player1Amount = cashAmount;         player2Amount = cashAmount;         rollAmount = 0;         betAmountPlayer1 = 100;         betAmountPlayer2 = 100;         numGames = 0;     }     public void rules()     {         Console.WriteLine("How the game works!");         Console.WriteLine("First: You can either set the custom cash amount for each player, or leave it default at $  1500.");         Console.WriteLine("Second: Select how many dice you want to roll(5,10,15,20).");         Console.WriteLine("Third: Ask each player how much they want to bet.");         //Console.WriteLine("Fourth: The higher your bet, the better chance you have at winning"); not implemented yet         Console.WriteLine("Lastly it will print the results, the new balance amounts, and ask if you want to play again.");     }      public void game()     {          Dice dice1 = new Dice();         Dice dice2 = new Dice();         string answer = "";          while (numGames == 0)         {             Console.Write("Would you like to leave the cash default(def) or set your own?(custom) ");             answer = Console.ReadLine();             if (!answer.ToLower().Equals("def") && !answer.ToLower().Equals("custom"))             {                 continue;             }             else                 break;         }         if (answer.ToLower().Equals("custom"))         {             string newAmount = "";             while (true)             {                 long temp = 0;                 Console.Write("Please enter your custom amount: ");                 newAmount = Console.ReadLine();                 if (Int64.TryParse(newAmount, out temp))                 {                     cashAmount = temp;                     player1Amount = cashAmount;                     player2Amount = cashAmount;                     break;                 }                 else                 {                     Console.WriteLine("ENTER A NUBMER");                     Console.WriteLine("");                     continue;                 }             }         }          // show amout to each player         Console.WriteLine("");         Console.WriteLine("Player 1 amount: " + player1Amount);         Console.WriteLine("Player 2 amount: " + player2Amount);          // ask how many dice they want to roll         while (true)         {             Console.WriteLine("");             Console.Write("How many dice would you like to roll?(5,10,15,20) ");             answer = Console.ReadLine();             if (!answer.ToLower().Equals("5") && !answer.ToLower().Equals("10") && !answer.ToLower().Equals("15") && !answer.ToLower().Equals("20"))             {                 Console.WriteLine("Enter a valid amount.");                 continue;             }             else                 break;          }          // ask how much each player wants to bet         while (true)         {             Console.WriteLine("");             Console.Write("Player 1 bet amount: ");             answer = Console.ReadLine();             if (Int64.TryParse(answer, out betAmountPlayer1))             {                 if (betAmountPlayer1 < 0 || betAmountPlayer1 > player1Amount)                 {                     Console.WriteLine("Please enter a valid number.");                     continue;                 }                 else if (betAmountPlayer1 <= player1Amount)                     break;             }             else             {                 Console.WriteLine("That is an invalid amount.");                 continue;             }         }          while (true)         {             Console.WriteLine("");             Console.Write("Player 2 bet amount: ");             answer = Console.ReadLine();             if (Int64.TryParse(answer, out betAmountPlayer2))             {                 if (betAmountPlayer2 < 0 || betAmountPlayer2 > player2Amount)                 {                     Console.WriteLine("Please enter a valid number.");                     continue;                 }                 else if (betAmountPlayer2 <= player2Amount)                     break;             }             else             {                 Console.WriteLine("That is an invalid amount.");                 continue;             }         }         // roll the dice         while (true)         {             if (Int32.TryParse(answer, out rollAmount))             {                 //Dice dice1 = new Dice();                 //Dice dice2 = new Dice();                 dice1.rollDiceNoShow(rollAmount, true);                 dice2.rollDiceNoShow(rollAmount, false);                 break;             }             else                 Console.WriteLine("Please enter a vaild number");             continue;         }          // print who had the higher sum         Console.WriteLine("");         Console.WriteLine("Player 1 had a score of: " + dice1.getPlayer1Sum());         Console.WriteLine("Player 2 had a score of: " + dice2.getPlayer2Sum());         Console.WriteLine("");         winner(dice1, dice2);          // ask if they want to play again      }      public void winner(Dice dice1, Dice dice2)     {         // check for the winner and update the cash amounts and show's their new balance          if(dice1.getPlayer1Sum() > dice2.getPlayer2Sum())         {             Console.WriteLine("Player 1 wins!");             Console.WriteLine("");             player1Amount += betAmountPlayer2;             player2Amount -= betAmountPlayer2;             Console.WriteLine("Player 1's new balance: " + player1Amount);             Console.WriteLine("Player 2's new balance: " + player2Amount);          }         else if (dice1.getPlayer1Sum() == dice2.getPlayer2Sum())         {             Console.WriteLine("It's a tie! no one wins!");             Console.WriteLine("");             Console.WriteLine("Player 1's balance: " + player1Amount);             Console.WriteLine("Player 2's balance: " + player2Amount);         }         else         {             Console.WriteLine("Player 2 wins!");             Console.WriteLine("");             player2Amount +=  betAmountPlayer1;             player1Amount -= betAmountPlayer1;             Console.WriteLine("Player 1's new balance: " + player1Amount);             Console.WriteLine("Player 2's new balance: " + player2Amount);         }      }     public void playAgain(string answer)     {         if (answer.ToLower().Equals("y"))         {             numGames++;         }     } }  class Dice {     private int player1Sum;     private int player2Sum;     private static int sides;     public Dice()     {         sides = 6;         player1Sum = 0;         player2Sum = 0;     }      public int rollDice(long nd) //nd = numDice     {         Random rand = new Random();         if (nd == 1)         {             int newSide = rand.Next(1, sides + 1);             return newSide;         }         for (int i = 1; i <= nd; i++)         {              int newSide = rand.Next(1, sides + 1);             Console.WriteLine("Dice Number " + i + " has landed on " + newSide);         }          return 0;     }      public void rollDiceNoShow(long nd, Boolean player1) //nd = numDice     {         Random rand = new Random();         // if there is only one dice         if (player1)         {             int newSide = rand.Next(1, sides + 1);             player1Sum += newSide;         }         else         {             int newSide = rand.Next(1, sides + 1);             player2Sum += newSide;         }          // more than one dice         if (player1)         {             for (int i = 1; i <= nd; i++)             {                  int newSide = rand.Next(1, sides + 1);                 player1Sum += newSide;             }         }         else         {             for (int i = 1; i <= nd; i++)             {                  int newSide = rand.Next(1, sides + 1);                 player2Sum += newSide;             }         }      }      public int getPlayer1Sum()     {          return player1Sum;     }      public int getPlayer2Sum()     {         return player2Sum;     } } 

A betting game using a dice class in C#

This is my first project over 100 lines and I would like some feedback on it. If anyone has any ideas for things to add or ways to make the code more efficient they would be very much appreciated.

class Program {     static void Main(string[] args)     {         Betting game1 = new Betting();         game1.rules();         Console.WriteLine("");         while (true)         {             game1.game();             string answer = "";             Console.WriteLine("");             while (true)             {                 Console.Write("Would you like to play again?(y or n) ");                 answer = Console.ReadLine();                 if (!answer.ToLower().Equals("y") && !answer.ToLower().Equals("n"))                 {                     Console.WriteLine("Please enter a valid answer.");                     Console.WriteLine("");                     continue;                 }                 else                     break;             }             if (answer.ToLower().Equals("y")) {                 game1.playAgain(answer);                 continue;             }             else                 break;         }     } }  class Betting {     private static long cashAmount;     private static long player1Amount;     private static long player2Amount;     private static int rollAmount;     private static long betAmountPlayer1;     private static long betAmountPlayer2;     private int numGames;       public Betting()     {         cashAmount = 1500;         player1Amount = cashAmount;         player2Amount = cashAmount;         rollAmount = 0;         betAmountPlayer1 = 100;         betAmountPlayer2 = 100;         numGames = 0;     }     public void rules()     {         Console.WriteLine("How the game works!");         Console.WriteLine("First: You can either set the custom cash amount for each player, or leave it default at $  1500.");         Console.WriteLine("Second: Select how many dice you want to roll(5,10,15,20).");         Console.WriteLine("Third: Ask each player how much they want to bet.");         //Console.WriteLine("Fourth: The higher your bet, the better chance you have at winning"); not implemented yet         Console.WriteLine("Lastly it will print the results, the new balance amounts, and ask if you want to play again.");     }      public void game()     {          Dice dice1 = new Dice();         Dice dice2 = new Dice();         string answer = "";          while (numGames == 0)         {             Console.Write("Would you like to leave the cash default(def) or set your own?(custom) ");             answer = Console.ReadLine();             if (!answer.ToLower().Equals("def") && !answer.ToLower().Equals("custom"))             {                 continue;             }             else                 break;         }         if (answer.ToLower().Equals("custom"))         {             string newAmount = "";             while (true)             {                 long temp = 0;                 Console.Write("Please enter your custom amount: ");                 newAmount = Console.ReadLine();                 if (Int64.TryParse(newAmount, out temp))                 {                     cashAmount = temp;                     player1Amount = cashAmount;                     player2Amount = cashAmount;                     break;                 }                 else                 {                     Console.WriteLine("ENTER A NUBMER");                     Console.WriteLine("");                     continue;                 }             }         }          // show amout to each player         Console.WriteLine("");         Console.WriteLine("Player 1 amount: " + player1Amount);         Console.WriteLine("Player 2 amount: " + player2Amount);          // ask how many dice they want to roll         while (true)         {             Console.WriteLine("");             Console.Write("How many dice would you like to roll?(5,10,15,20) ");             answer = Console.ReadLine();             if (!answer.ToLower().Equals("5") && !answer.ToLower().Equals("10") && !answer.ToLower().Equals("15") && !answer.ToLower().Equals("20"))             {                 Console.WriteLine("Enter a valid amount.");                 continue;             }             else                 break;          }          // ask how much each player wants to bet         while (true)         {             Console.WriteLine("");             Console.Write("Player 1 bet amount: ");             answer = Console.ReadLine();             if (Int64.TryParse(answer, out betAmountPlayer1))             {                 if (betAmountPlayer1 < 0 || betAmountPlayer1 > player1Amount)                 {                     Console.WriteLine("Please enter a valid number.");                     continue;                 }                 else if (betAmountPlayer1 <= player1Amount)                     break;             }             else             {                 Console.WriteLine("That is an invalid amount.");                 continue;             }         }          while (true)         {             Console.WriteLine("");             Console.Write("Player 2 bet amount: ");             answer = Console.ReadLine();             if (Int64.TryParse(answer, out betAmountPlayer2))             {                 if (betAmountPlayer2 < 0 || betAmountPlayer2 > player2Amount)                 {                     Console.WriteLine("Please enter a valid number.");                     continue;                 }                 else if (betAmountPlayer2 <= player2Amount)                     break;             }             else             {                 Console.WriteLine("That is an invalid amount.");                 continue;             }         }         // roll the dice         while (true)         {             if (Int32.TryParse(answer, out rollAmount))             {                 //Dice dice1 = new Dice();                 //Dice dice2 = new Dice();                 dice1.rollDiceNoShow(rollAmount, true);                 dice2.rollDiceNoShow(rollAmount, false);                 break;             }             else                 Console.WriteLine("Please enter a vaild number");             continue;         }          // print who had the higher sum         Console.WriteLine("");         Console.WriteLine("Player 1 had a score of: " + dice1.getPlayer1Sum());         Console.WriteLine("Player 2 had a score of: " + dice2.getPlayer2Sum());         Console.WriteLine("");         winner(dice1, dice2);          // ask if they want to play again      }      public void winner(Dice dice1, Dice dice2)     {         // check for the winner and update the cash amounts and show's their new balance          if(dice1.getPlayer1Sum() > dice2.getPlayer2Sum())         {             Console.WriteLine("Player 1 wins!");             Console.WriteLine("");             player1Amount += betAmountPlayer2;             player2Amount -= betAmountPlayer2;             Console.WriteLine("Player 1's new balance: " + player1Amount);             Console.WriteLine("Player 2's new balance: " + player2Amount);          }         else if (dice1.getPlayer1Sum() == dice2.getPlayer2Sum())         {             Console.WriteLine("It's a tie! no one wins!");             Console.WriteLine("");             Console.WriteLine("Player 1's balance: " + player1Amount);             Console.WriteLine("Player 2's balance: " + player2Amount);         }         else         {             Console.WriteLine("Player 2 wins!");             Console.WriteLine("");             player2Amount +=  betAmountPlayer1;             player1Amount -= betAmountPlayer1;             Console.WriteLine("Player 1's new balance: " + player1Amount);             Console.WriteLine("Player 2's new balance: " + player2Amount);         }      }     public void playAgain(string answer)     {         if (answer.ToLower().Equals("y"))         {             numGames++;         }     } }  class Dice {     private int player1Sum;     private int player2Sum;     private static int sides;     public Dice()     {         sides = 6;         player1Sum = 0;         player2Sum = 0;     }      public int rollDice(long nd) //nd = numDice     {         Random rand = new Random();         if (nd == 1)         {             int newSide = rand.Next(1, sides + 1);             return newSide;         }         for (int i = 1; i <= nd; i++)         {              int newSide = rand.Next(1, sides + 1);             Console.WriteLine("Dice Number " + i + " has landed on " + newSide);         }          return 0;     }      public void rollDiceNoShow(long nd, Boolean player1) //nd = numDice     {         Random rand = new Random();         // if there is only one dice         if (player1)         {             int newSide = rand.Next(1, sides + 1);             player1Sum += newSide;         }         else         {             int newSide = rand.Next(1, sides + 1);             player2Sum += newSide;         }          // more than one dice         if (player1)         {             for (int i = 1; i <= nd; i++)             {                  int newSide = rand.Next(1, sides + 1);                 player1Sum += newSide;             }         }         else         {             for (int i = 1; i <= nd; i++)             {                  int newSide = rand.Next(1, sides + 1);                 player2Sum += newSide;             }         }      }      public int getPlayer1Sum()     {          return player1Sum;     }      public int getPlayer2Sum()     {         return player2Sum;     } } 

The Best Football Betting Tips and Football Prediction Site

[​IMG]

Why TipsPortal is the best football betting tips and football prediction site compared to the other?

TipsPortal is the best football prediction site that help millions of people make consistent profits using our football tips provided by our experts. Please keep in mind that there are no fixed games or fixed matches on TipsPortal. But we work…

The Best Football Betting Tips and Football Prediction Site

I made a console Blackjack game. Just no split and no betting system for now

So, I never programmed in my life, and I am currently self teaching me some C++. After beginning to read about OOS and classes, and after seeing that a Blackjack game would be something simple to implement using the console, I created the following program to play Blackjack on the console (No graphics, just text narrating what’s going on).

Features:

  • Aces can be worth 1 or 11, depending on what’s better for the score.
  • Dealer forced to hit if it has a soft 17 (score of 17 with at least one Ace).

Not implemented:

  • Betting system – The player ether lose, tie or win.
  • Split system – The player can’t split his hand if dealt a pair.

C O D E :

card.h

#ifndef CARD_H #define CARD_H  #include <iostream>  class Card { public:     enum CardSuit     {         CS_S,         CS_D,         CS_C,         CS_H,         CS_MAX     };      enum CardRank     {         CR_2,         CR_3,         CR_4,         CR_5,         CR_6,         CR_7,         CR_8,         CR_9,         CR_T,         CR_J,         CR_Q,         CR_K,         CR_A,         CR_MAX     };  private:     CardSuit m_suit;     CardRank m_rank;  public:     Card(CardSuit suit = CS_S, CardRank rank = CR_A)     :   m_suit {suit},         m_rank {rank}     { }      void printCard() const;     int getCardValue() const; };  #endif 

card.cpp

#include "card.h"  void Card::printCard() const {     switch (m_rank)     {         case CR_2: std::cout << '2'; break;         case CR_3: std::cout << '3'; break;         case CR_4: std::cout << '4'; break;         case CR_5: std::cout << '5'; break;         case CR_6: std::cout << '6'; break;         case CR_7: std::cout << '7'; break;         case CR_8: std::cout << '8'; break;         case CR_9: std::cout << '9'; break;         case CR_T: std::cout << 'T'; break;         case CR_J: std::cout << 'J'; break;         case CR_Q: std::cout << 'Q'; break;         case CR_K: std::cout << 'K'; break;         case CR_A: std::cout << 'A'; break;     }      switch (m_suit)     {         case CS_S: std::cout << 'S'; break;         case CS_D: std::cout << 'D'; break;         case CS_C: std::cout << 'C'; break;         case CS_H: std::cout << 'H'; break;     } }  int Card::getCardValue() const {     switch (m_rank)     {         case CR_2: return 2;         case CR_3: return 3;         case CR_4: return 4;         case CR_5: return 5;         case CR_6: return 6;         case CR_7: return 7;         case CR_8: return 8;         case CR_9: return 9;         case CR_T: return 10;         case CR_J: return 10;         case CR_Q: return 10;         case CR_K: return 10;         case CR_A: return 11;     }     return 0; } 

deck.h

#ifndef DECK_H #define DECK_H  #include "card.h" #include <array> #include <vector> #include <iostream>  class Deck { private:     std::array<Card, 52> m_card;     int m_cardIndex;      void swapCard(Card &a, Card &b);     inline Card* dealCard();  public:     std::vector<Card*> m_playerHand;     std::vector<Card*> m_dealerHand;      Deck() : m_cardIndex {0}, m_playerHand {}, m_dealerHand {}     {         int index {0};         for (int iii {0}; iii < Card::CS_MAX; ++iii)         {             for (int jjj {0}; jjj < Card::CR_MAX; ++jjj)             {                 m_card[index] = Card(static_cast<Card::CardSuit>(iii), static_cast<Card::CardRank>(jjj));                 ++index;             }         }     }      void printDeck() const;     void shuffleDeck(int xTimes);     void dealPlayer();     void dealDealer(); };  inline Card* Deck::dealCard() {     return &m_card[m_cardIndex++]; }  #endif 

deck.cpp

#include "deck.h" #include <random> #include <chrono>  namespace Rng {     const auto seed {std::chrono::high_resolution_clock::now().time_since_epoch().count()};     std::mt19937 mt {static_cast<unsigned long int>(seed)};      int rng(int min, int max)     {         std::uniform_int_distribution<> rng {min, max};         return rng(mt);     } }  void Deck::swapCard(Card &a, Card &b) {     Card temp {a};     a = b;     b = temp; }  void Deck::printDeck() const {     for (int iii {0}; iii < 52; ++iii)     {         m_card[iii].printCard();         if (((iii + 1) % 13 == 0) && iii != 0)             std::cout << '\n';         else             std::cout << ' ';     } }  void Deck::shuffleDeck(int xTimes = 1) {     for (int iii {0}; iii < xTimes; ++iii)     {         for (int jjj {0}; jjj < 52; ++jjj)         {             swapCard(m_card[jjj], m_card[Rng::rng(0, 51)]);         }     }     m_cardIndex = 0;     m_playerHand.clear();     m_dealerHand.clear(); }  void Deck::dealPlayer() {     int index {static_cast<int>(m_playerHand.size())};     m_playerHand.resize(index + 1);     m_playerHand[index] = dealCard(); }  void Deck::dealDealer() {     int index {static_cast<int>(m_dealerHand.size())};     m_dealerHand.resize(index + 1);     m_dealerHand[index] = dealCard(); } 

main.cpp

#include "card.h" #include "deck.h" #include <iostream> #include <vector> #include <string>  int getPoints(std::vector<Card*> &hand) {     int score {0};     int acesCount {0};     for (auto &card : hand)     {         score += card->getCardValue();         if (card->getCardValue() == 11)             ++acesCount;     }     if (score > 21 && acesCount != 0)     {         do         {             score -= 10;             --acesCount;         } while (score > 21 && acesCount > 0);     }     return score; }  bool dealerHit(std::vector<Card*> dealerHand) {     return false; }  void playGame(Deck &gameDeck) {     gameDeck.shuffleDeck(20);     gameDeck.dealPlayer();     gameDeck.dealDealer();     gameDeck.dealPlayer();     gameDeck.dealDealer();     std::cout << "You were dealt |";     gameDeck.m_playerHand[0]->printCard();     std::cout << "| |";     gameDeck.m_playerHand[1]->printCard();     std::cout << "|\nDealer was dealt |";     gameDeck.m_dealerHand[0]->printCard();     std::cout << "| and a card facing down\nThe dealer peaks at the hole card.\n";     int playerScore {getPoints(gameDeck.m_playerHand)};     int dealerScore {getPoints(gameDeck.m_dealerHand)};     if (playerScore == 21 && dealerScore != 21)     {         std::cout << "You have a Blackjack!\n"                      "You win the game.";         return;     }     else if (dealerScore == 21 && playerScore != 21)     {         std::cout << "The dealer flips the hole card to reveal "                      "a Blackjack with cards |";         gameDeck.m_dealerHand[0]->printCard();         std::cout << "| and |";         gameDeck.m_dealerHand[1]->printCard();         std::cout << "|\nYou lose the game.\n";         return;     }     else if (playerScore == 21 && dealerScore == 21)     {         std::cout << "You have a Blackjack.\n"                      "The dealer flips the hole card to reveal"                      "a Blackjack with cards |";         gameDeck.m_dealerHand[0]->printCard();         std::cout << "| and |";         gameDeck.m_dealerHand[1]->printCard();         std::cout << "|\nThe game is a tie\n.";         return;     }     // Player Hit loop:     bool exitPlayerLoop {false};     while (!exitPlayerLoop)     {         std::cout << "Choose your action: [H]it or [S]tand\n";         std::string action {};         std::cin >> action;         switch (action.front())         {         case 'h':         case 'H':         {             gameDeck.dealPlayer();             std::cout << "You were dealt a |";             gameDeck.m_playerHand[gameDeck.m_playerHand.size() - 1]->printCard();             std::cout << "|\nYour hand is";             for (auto &card : gameDeck.m_playerHand)             {                 std::cout << " |";                 card->printCard();                 std::cout << '|';             }             std::cout << '\n';             playerScore = getPoints(gameDeck.m_playerHand);             if (playerScore > 21)             {                 std::cout << "You busted. You lose the game.\n\n";                 return;             }         }         break;         case 's':         case 'S':         {             std::cout << "You stood. Your hand is";             for (auto &card : gameDeck.m_playerHand)             {                 std::cout << " |";                 card->printCard();                 std::cout << '|';             }             exitPlayerLoop = true;         }         break;         default:             std::cout << "Invalid input\n";         }     }     std::cout << "\nThe dealer flips the hole card. It reveals a |";     gameDeck.m_dealerHand[1]->printCard();     std::cout << "|\n";     // Dealer hit loop:     bool exitDealerLoop {false};     while (!exitDealerLoop)     {         int dealerAcesCount {0};         for (auto &card : gameDeck.m_dealerHand)         {             if (card->getCardValue() == 11)                 ++dealerAcesCount;         }         dealerScore = getPoints(gameDeck.m_dealerHand);         if (dealerScore < 17 || (dealerScore == 17 && dealerAcesCount > 0))         {             gameDeck.dealDealer();             std::cout << "Dealer hits and was dealt a |";             gameDeck.m_dealerHand[gameDeck.m_dealerHand.size() - 1]->printCard();             std::cout << "|\n";             continue;         }         std::cout << "Dealer hand:";         for (auto &card : gameDeck.m_dealerHand)         {             std::cout << " |";             card->printCard();             std::cout << '|';         }         std::cout << '\n';         exitDealerLoop = true;     }     playerScore = getPoints(gameDeck.m_playerHand);     dealerScore = getPoints(gameDeck.m_dealerHand);     if (dealerScore > 21)     {         std::cout << "The dealer busted. You win the game!\n\n";     }     else if (playerScore > dealerScore)     {         std::cout << "You win the game!\n\n";     }     else if (playerScore < dealerScore)     {         std::cout << "You lose the game.\n\n";     }     else if (playerScore == dealerScore)     {         std::cout << "The game is a draw.\n\n";     }     return; }  int main() {     std::cout << "         Welcome to Blackjack!\n"                  "* * RULES: Dealer must hit soft 17 * *\n\n";     Deck gameDeck;     bool exitLoop {false};     while (!exitLoop)     {         playGame(gameDeck);         bool validChoice = false;         while (!validChoice)         {             std::cout << "Play again? <Y/N>\n";             std::string choice {};             std::cin >> choice;             switch (choice.front())             {             case 'y':             case 'Y':                 validChoice = true;                 break;             case 'n':             case 'N':                 validChoice = true;                 exitLoop = true;                 break;             default:                 std::cout << "Invalid choice.\n";             }         }     }     std::cout << "\nThank you for playing!\n";     return 0; } 

I tried to put in functions the methods that were used more than once only, hence the big size of the void playGame(Deck &gameDeck) function.

Considering that I am just beginning to learn the language, I want some improvement advice: What are my bad habits? Should I separate the huge void playGame(Deck &gameDeck) function into smaller ones? Am I doing the multi file division the right way? I aimed for a file and header per class. Anything you guys would change to this particular program? Any advice to me in general?

Best regards and thank you all!

PS: Can I move those enums out of the header file? I tried but with no success. They look ugly in a header file…

100 Casino Blog post- Casino – Gambling – Poker – Betting – sports sites From Web2.0 Poperties for $50

100 Online Casino & Gambling Related Backlinks from my Blog Networks Related Backlinks Are More Powerfull for any sites. For This reason my service Online Casino & Gambling or Poker Related Blog post Service. Blog, blogger and Kinja most popular blogging platform, It is a new power for the internet marketing, which boost your search engine rankings, Google always values links from trusted sources and high authority websites like Blog, blogger and Kinja and most interesting part is that Google Loves those links. Main Features: # Online Casino & Gambling Related Backlinks from my Blog Networks (Backliks from 5 Media Platform) # Manually Done (NOT ROBOTS) # Permanent and High Authority Backlinks # 100% Quality Article # 100% Unique Human-readable 400-600 words content with relevant images in all PBN posts # One Contextual link per post # Keywords/Anchor Text (1 Post 1 keyword) # Limited Offer and Different From Other Sellers # Detailed report # Guaranteed order delivered within 48 hours # Anything Related To Casino, Gambling, poker, Abobet, Jodi bola and more… # 100% SATISFACTION GUARANTEE F.A.Q Do you provide report? Yes! you will get complete report after workdone. Can i see Samples? Yes! Please Pm me for samples Is this a onetime fee? Yes, we charge onetime fee and links arepermanent Do you accept foreign language keywords/website? Yes, we do – although your content will be inEnglish. How many URL and Keywords are allowed? Everyone has their own SEO plan. So you should know the ratio of keywords for better ranking. We recommended use long tail keywords for long-term results. We can accept unlimited keywords and URL.

by: BacklinkAgency
Created: —
Category: Link Building
Viewed: 376


Guest Post for Gambling | Casino | Sports | Betting Sites for $90

Guest Post for Gambling | Casino | Sports | Betting Sites with And Tier-: 100 Link (profile, web2.0, bookmarks, edu links…. etc…) A Casino, Gambling and Batting websites you are owning and want to boost them, Then My services is best option for you to Achieve your Target. and #1 High Quality Contextual Back links # 400-600 word Related Content published # 1 Contextual Backlinks from our top authority Blogs # Related Image/video add Every Post # all Post Home Page Boost your Gambling or casino poker websites with Related Backlinks Service..

by: TrustLinks
Created: —
Category: Blog Comments
Viewed: 311