I have found similar issues on this forum but none that quite answer my question. I'm trying to write my first basic program, a simple blackjack game.
My idea is to use an enum for the suits and values;
private enum CardValue //enum for card values
{
Two = 2,
Three,Four,Five, Six, Seven,
Eight,Nine,Ten,
Jack = 10,
Queen = 10,
King = 10,
Ace
}
I then make a 52 element array of this type to represent the deck and shuffle it. The problem is that when I print out the shuflled values 'Jack' 'Queen' and 'King' all print out as 'jack', I'm assuming because they all have the same underlying INT value. I want to be able to do it this way to cast the values back to INT to add up the totals in the game.
10is a Jack, and another10is a King? It's the same pattern of bits, they cannot be distinguished. Sounds like you need to use a class instead of an enum. Or give your enum values unique integers, and define aDictionary<Card, int>to record their values.Ace? It's either1or11..