Byt3
New member
- Joined
- Dec 10, 2019
- Messages
- 1
- Programming Experience
- Beginner
It supposed to return 54 cards, including 2 jokers. But it is only return 41 elements. There are cards missing. Please help...
Generate Deck method:
List<List<string>> GenerateDeck() {
List<string> ranks = new List<string>();
List<string> suits = new List<string>();
suits.Add("clubs");
suits.Add("spades");
suits.Add("diamonds");
suits.Add("hearts");
for (int i = 1; i <= 13; i++) {
switch (i) {
case 1:
ranks.Add("ace");
break;
case 11:
ranks.Add("jack");
break;
case 12:
ranks.Add("queen");
break;
case 13:
ranks.Add("king");
break;
default:
ranks.Add(i.ToString());
break;
}
}
Console.WriteLine("ranks count: " + ranks.Count);
Console.WriteLine("suits count: " + suits.Count);
List<List<string>> deck = new List<List<string>>();
foreach (string rank in ranks) {
foreach (string suit in suits) {
deck.Add(new List<string> { rank, suit });
}
}
deck.Add(new List<string> { "red", "joker"});
deck.Add(new List<string> { "black", "joker"});
Console.WriteLine("deck count: " + deck.Count); // deck count: 54
Console.WriteLine();
Console.WriteLine("TEMP DECK:");
Console.WriteLine();
foreach (List<string> card in deck)
Console.WriteLine(card[0] + " " + card[1]);
return deck; // returns 41 elements
}
Last edited by a moderator: