I’m writing a blackjack program. I created the class card which contains two strings and an integer. ‘dealer’ is a vector of class ‘card’, ‘dtotal’ and ‘deckplace’ are both integers. ‘display()’ is a function that prints the cards, suits, and totals. The error occurs in the line above “else if (total>16)”.
void dealerTurn()
{
if (dtotal<17)
{
do while (dtotal<17)
{
dealer.pop_back(deck[deckplace]);
deckplace = deckplace+1;
for (y=0;y<dealer.size();y++)
{
if (dealer[y].name=="A" && dtotal>21)
{
dealer[y].value = 1;
dtotal = 0;
for (z=0;z<dealer.size();z++)
dtotal = dtotal + dealer[z].value;
}
}
display();
if (dtotal>21)
{
cout << endl << "-----DEALER BUSTED!-----" << endl << endl;
dtotal = 0;
}
}
}
else if (total>16)
{
display();
}
result();
}
There is no such thing as
do while. It is eitherwhile (__condition__) { __statements__ }ordo { __statements__ } while (__condition__);.