Quote:
|
But have you removed some print outputs?
|
Not really. I just outcommented them.
Find the outcommented code:
Code:
void BlackJack::Shuffle()
{
//pre shuffle
/* m_Deck.Show(cout);
cout<<endl; */
m_Deck.Shuffle();
//Show the deck. The traditional way. Using a simple loop:
/* for(int i = 0; i<m_Deck.getDeck().size(); ++i)
{
cout<<m_Deck.getDeck()[ i ]<<endl;
}
cout<<endl<<endl; */
//An elegant way below, using the overloaded operator and a
//Nice demonstration of the vector::copy() method (rarely used
//because people seem not to know how to use it).
/* m_Deck.Show(cout); */
}
Quote:
|
Also when for Hit or stand if we press anything else than key 1 or 0 then things go wrong. so we could have a test where we check if key is 0 or 1 and if not just print that press key 1 or key 0 instead!
|
The fact that things go wrong if you press a non-numeric key has been fixed in the version you can download below. So pressing a character (or a string) is fixed. But ONLY in the method where you're asked for your wager (that one was buggy too).
There is another one left to fix: When pressing a character (or a string in general) when computer asks you if you stand or hit. I did that on purpose!
Try it yourself. It is basic routine wich one should learn.
You also asked to skip for feedback on wich key(s) to press. What do you want? That strangers should guess wich keys are allowed to press?
Think again.
Quote:
A hand consist of two cards in Blackjack game so when u give card
void BlackJack::GiveCard(Player& plyr)
{
plyr.Hand.push_back(*m_Deck.getDeck().begin());
m_Deck.RemoveTopCard();
}
can we use loop to give 2 cards instead?
|
Then you might not have understood how the method works: Just code twice:
Code:
GiveCard(thePlayer)
m_Deck.RemoveTopCard();
GiveCard(thePlayer)
m_Deck.RemoveTopCard();
You do that in the
Go() method. And guess what...
Even I implemented the casino rules (like we play it here in our country), the game still works. The stability is really of a mature level

!
In many casinos you can double your wager when you received your first card, if is a 9, 10 or Ace. But then you will receive one card ONLY. Better hope it is something good. You won't get anymore than two.
But your wish for dealing two cards in the first turn eliminates that option. And vice versa, if I implement this rule ( I will becase I like it), then dealing two card for one player in the first turn won't go anymore.
You can download the updated code below. It has even a smarter dealer!
The previous one wasn't good with aces :p.
blackjackvc6final