it's in c++
The idea was to set it up so that it will keep looping through all the cards to keep getting different results and answers until all 52 cards are gone i dont know the exact placmet for it I know its
for(int i = 0; i < 5; i++)
{
cout << i << endl;
}
I wasn't quite sure how to set up the array If I just did it like string {ace, one two} and so on.. but I have the array labeled 52 even typing them all out its only 13 number repeated 4 times in 4 suits so would you class them all separately? Or is there something for that?
#include <iostream>
using namespace std;
class cardGame;
int main()
{
int bet;
int dealer[52] = { 13, 13, 13, 13 };
int player[52] = { 13, 13, 13, 13 };
int dealerCard1;
int dealerCard2;
int playerCard1;
int playerCard2;
int dealerTotal;
int playerTotal;
int shuffle;
cout << "This is My attempt at BlackJack" << endl;
cout << endl;
cin >> bet;
cout << "Player enter amount to bet: $ ";
cout << endl;
cin >> shuffle;
cardGame::playeer(playerCard1 + playerCard2 = playerTotal);
cardsGame.playerCard1 = 0;
cardsGame.playerCard2 = 0;
cardsGame.playerTotal = 0;
cout << "the First card is: " << cardsGame.playerCard1 = 0 << endl;
cout << "The second card is: " << cardsGame.playerCard = 0 << endl;
cout << "Your total is: " << cardsGame.playerTotal = 0 << endl;
cardGame::playeer(playerCard1 + playerCard2 = playerTotal);
if (playerCard1 + playerCard2 == 21)
{
cout << "WINNER WINNER CHICKEN DINNER!" << endl;
};
else (playerCard1 + playerCard2 > 21)
{
cout << "What a dissapointment you are to everyone!" << endl;
};
if (playerCard1 + playerCard2 > dealerTotal)
{
cout << "WINNER WINNER CHICKEN DINNER!" << endl;
};
else (playerCard1 + playerCard2 == dealerTotal)
{
cout << "What a dissapointment you are to everyone!"
}
cardGame::dealer(dealerCard1 + dealerCard2 = dealerTotal);
cardsGame.dealerCard1 = 0;
cardsGame.dealerCard2 = 0;
cardsGame.dealerTotal = 0;
cout << "the First card is: " << cardsGame.dealerCard1 = 0 << endl;
cout << "The second card is: " << cardsGame.dealerCard2 = 0 << endl;
cout << "Your total is: " << cardsGame.dealerTotal = 0 << endl;
cardGame::dealer(dealerCard1 + playerCard2 = playerTotal);
if (dealerCard1 + dealerCard2 == 21)
{
cout << "What a dissapointment you are to everyone!" << endl;
};
else (dealerCard1 + dealerCard2 > 21)
{
cout << "WINNER WINNER CHICKEN DINNER" << endl;
}
if (dealerCard1 + dealerCard2 > playerTotal)
{
cout << "What a dissapointment you are to everyone!" << cout endl:
};
else (dealerCard1 + dealerCard2 < playerTotal)
{
cout << "What a dissapointment you are to everyone!"
}
}
I don't know c++ (or blackjack); but below is an example in Javascript which illustrates some concepts and might push you in the right direction.
In terms of structure you might want something like:
// Set up your 'deck'
deck = {
hearts: [],
spades: [],
diamonds: [],
clubs: []
}
// The object 'deck' has four properties (hearts, spades...), each of which is an empty array.
// Use a loop to add your 'cards'
Object.keys(deck).forEach(suit => {
for (i = 1; i < 14; i++) {
deck[suit].push(i);
}
});
// For each property in the object 'deck', push ascending consecutive integers starting from the number 1 to each array, until the number 14 is reached.
This gives you:
deck = {
hearts: [1,2,3,4,5,6,7,8,9,10,11,12,13],
spades: [1,2,3,4,5,6,7,8,9,10,11,12,13],
diamonds: [1,2,3,4,5,6,7,8,9,10,11,12,13],
clubs: [1,2,3,4,5,6,7,8,9,10,11,12,13]
}