One function inputs 24 random strings into an string list from an array with a for loop. The other function displays the strings from the list in the console. However I get only one value looped for example like 1111111111111111111111111. When I set breakpoint, I get the output I was looking for such as 12kingace342356110. Here's my function class code.
namespace CardWarConsoleGame
{
class Deck
{
public string[] CardNames = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace" };
public int[] CardValues = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
}
class WarFunctions
{
public static List<string> YourDeck = new List<string>();
public static List<string> AIDeck = new List<string>();
public static void LoadCards()
{
Deck deck = new Deck();
for (int i = 0; i < 24; i++)
{
Random r = new Random();
YourDeck.Add(deck.CardNames[r.Next(0, 14)]);
}
}
public static void test()
{
for (int i = 0; i < YourDeck.Count; i++)
{
Console.Write(YourDeck[i]);
}
}
}
}
Heres the program.cs
namespace CardWarConsoleGame
{
class Program : WarFunctions
{
static void Main(string[] args)
{
LoadCards();
test();
Console.ReadLine();
}
}
}