0
Could someone help me figure out why the aces wont work. I have really tried but i cannot figure out why the logic will not work
11 odpowiedzi
+ 1
instead of c1.number = srand...
try this
c1.number = srand...
int Number = c1.number;
c1.type = cardType(Number)
also for the card names you should probably just use a char if its one letter
+ 1
thanks Hazer I did change the string to char but don't know how everything else will help my if logic for an ace
+ 1
Benjamin Moody Your code is very confusing, but i did notice 1 thing as i started to look at it your line
total1 = playerCards[0] + playerCards[1];
this line is run right after you randomly generate numbers from 1-13 so if you get 11-13 in one of the 2 numbers its not going to add 10 it is going to add 11, 12 or 13.
I will look threw the if statements when i get a chance that is just one thing i noticed.
+ 1
thank you mooaholic for looking at my code I tried to add some comments but I need it to generate 1-13 to get the card face value, where 11 = 'J' (jack), 12 = 'Q' (queen), and 13 = 'K' (king). but later I have an if statement that sets the value is > 10 then it = 10. don't know if that makes sense or helps at all.
+ 1
Benjamin Moody yes i see that the
if(c1.number > 10){
playerCards[0] = 10;
}
and you have one for card 2, but the problem is you have your total1 = playerCards[0] + playerCards[1];
before both those if statments, so you are adding the wrong values for J-K you need to move those 2 if statments above the total1 = line. that should fix your problem with the first 2 cards.
+ 1
my problem is
if(c1.number == 1 && total1 <= 10)
{ total1 += 10;} if you get an ace for one of your first two cards you want it to equal 11 but if you get two aces you want one to equal 11 and the other to equal 1
+ 1
for me it did, i got 2 1’s and it gave me a total of 12
+ 1
thank you I will have to wait till I can get on my computer to change it. I have to still add a dealer hand.
+ 1
Benjamin Moody one other thing i noticed is that if you play and choose 1 and 3 as inputs so you get 2 cards and stay your first total it tells you is correct but if any of the other 3 generated cards are 1(Ace) or Ten-Jack-Queen-King, then the second total you get is wrong because it still adds or subtracts the 10 from your if statments later on in the code.
0
thank you for your help and I know I still have a little work to do. I will keep working on it for sure. may need some help in the future lol
0
Benjamin Moody i will help as much as i can when you need me.